From: Todd C. Miller Date: Thu, 18 May 2017 19:53:15 +0000 (-0600) Subject: To avoid overwriting existing command status, check for CMD_INVALID X-Git-Tag: SUDO_1_8_21^2~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad8c1ae07ab2d248b03eeaa5b23f1092744c787a;p=sudo To avoid overwriting existing command status, check for CMD_INVALID instead of CMD_ERRNO or CMD_WSTATUS. --- diff --git a/src/exec_monitor.c b/src/exec_monitor.c index 6d28a296c..c52833edd 100644 --- a/src/exec_monitor.c +++ b/src/exec_monitor.c @@ -193,7 +193,7 @@ mon_handle_sigchld(struct monitor_closure *mc) } /* Don't overwrite execve() failure with child exit status. */ - if (mc->cstat->type != CMD_ERRNO) { + if (mc->cstat->type == CMD_INVALID) { /* * Store wait status in cstat and forward to parent if stopped. */ diff --git a/src/exec_nopty.c b/src/exec_nopty.c index 3c14c46e8..77362eaa0 100644 --- a/src/exec_nopty.c +++ b/src/exec_nopty.c @@ -550,7 +550,7 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec) __func__, (int)ec->cmnd_pid, WEXITSTATUS(status)); } /* Don't overwrite execve() failure with command exit status. */ - if (ec->cstat->type != CMD_ERRNO) { + if (ec->cstat->type == CMD_INVALID) { ec->cstat->type = CMD_WSTATUS; ec->cstat->val = status; } diff --git a/src/exec_pty.c b/src/exec_pty.c index e075a508b..4d4811bf4 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -734,7 +734,7 @@ backchannel_cb(int fd, int what, void *v) /* Nothing ready. */ break; default: - if (ec->cstat->val != CMD_WSTATUS) { + if (ec->cstat->val == CMD_INVALID) { ec->cstat->type = CMD_ERRNO; ec->cstat->val = errno; sudo_debug_printf(SUDO_DEBUG_ERROR, @@ -795,7 +795,7 @@ backchannel_cb(int fd, int what, void *v) break; default: /* Short read, should not happen. */ - if (ec->cstat->val != CMD_WSTATUS) { + if (ec->cstat->val == CMD_INVALID) { ec->cstat->type = CMD_ERRNO; ec->cstat->val = EIO; sudo_debug_printf(SUDO_DEBUG_ERROR,