qrexec: process vchan data queue (esp MSG_EXIT_CODE) before sending anything
In case of remote process exit even when some messages are still waiting, vchan connection can be already closed. If we try to send some data in this case (for example stdout of local process), there will be an error, which will terminate qrexec-client-vm/qrexec-agent child. So first check vchan data (where could be MSG_EXIT_CODE queued) , then local process. There is still some race condition in this code - remote process could exit just after we check vchan, but before we send some data. But this is much less probable and in the worst case we only loose remote process exit code.
This commit is contained in:
parent
16c27fc409
commit
8f00bdb4a6
@ -361,26 +361,6 @@ int process_child_io(libvchan_t *data_vchan,
|
||||
handle_vchan_error("wait");
|
||||
}
|
||||
|
||||
if (stdout_fd >= 0 && FD_ISSET(stdout_fd, &rdset)) {
|
||||
switch (handle_input(data_vchan, stdout_fd, stdout_msg_type)) {
|
||||
case -1:
|
||||
handle_vchan_error("send");
|
||||
break;
|
||||
case 0:
|
||||
stdout_fd = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stderr_fd >= 0 && FD_ISSET(stderr_fd, &rdset)) {
|
||||
switch (handle_input(data_vchan, stderr_fd, MSG_DATA_STDERR)) {
|
||||
case -1:
|
||||
handle_vchan_error("send");
|
||||
break;
|
||||
case 0:
|
||||
stderr_fd = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* handle_remote_data will check if any data is available */
|
||||
switch (handle_remote_data(data_vchan, stdin_fd, &remote_process_status)) {
|
||||
case -1:
|
||||
@ -403,6 +383,26 @@ int process_child_io(libvchan_t *data_vchan,
|
||||
return remote_process_status;
|
||||
break;
|
||||
}
|
||||
if (stdout_fd >= 0 && FD_ISSET(stdout_fd, &rdset)) {
|
||||
switch (handle_input(data_vchan, stdout_fd, stdout_msg_type)) {
|
||||
case -1:
|
||||
handle_vchan_error("send");
|
||||
break;
|
||||
case 0:
|
||||
stdout_fd = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (stderr_fd >= 0 && FD_ISSET(stderr_fd, &rdset)) {
|
||||
switch (handle_input(data_vchan, stderr_fd, MSG_DATA_STDERR)) {
|
||||
case -1:
|
||||
handle_vchan_error("send");
|
||||
break;
|
||||
case 0:
|
||||
stderr_fd = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return child_process_status;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user