To avoid overwriting existing command status, check for CMD_INVALID

instead of CMD_ERRNO or CMD_WSTATUS.
This commit is contained in:
Todd C. Miller
2017-05-18 13:53:15 -06:00
parent 47df575f68
commit ad8c1ae07a
3 changed files with 4 additions and 4 deletions

View File

@@ -193,7 +193,7 @@ mon_handle_sigchld(struct monitor_closure *mc)
} }
/* Don't overwrite execve() failure with child exit status. */ /* 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. * Store wait status in cstat and forward to parent if stopped.
*/ */

View File

@@ -550,7 +550,7 @@ handle_sigchld_nopty(struct exec_closure_nopty *ec)
__func__, (int)ec->cmnd_pid, WEXITSTATUS(status)); __func__, (int)ec->cmnd_pid, WEXITSTATUS(status));
} }
/* Don't overwrite execve() failure with command exit 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->type = CMD_WSTATUS;
ec->cstat->val = status; ec->cstat->val = status;
} }

View File

@@ -734,7 +734,7 @@ backchannel_cb(int fd, int what, void *v)
/* Nothing ready. */ /* Nothing ready. */
break; break;
default: default:
if (ec->cstat->val != CMD_WSTATUS) { if (ec->cstat->val == CMD_INVALID) {
ec->cstat->type = CMD_ERRNO; ec->cstat->type = CMD_ERRNO;
ec->cstat->val = errno; ec->cstat->val = errno;
sudo_debug_printf(SUDO_DEBUG_ERROR, sudo_debug_printf(SUDO_DEBUG_ERROR,
@@ -795,7 +795,7 @@ backchannel_cb(int fd, int what, void *v)
break; break;
default: default:
/* Short read, should not happen. */ /* Short read, should not happen. */
if (ec->cstat->val != CMD_WSTATUS) { if (ec->cstat->val == CMD_INVALID) {
ec->cstat->type = CMD_ERRNO; ec->cstat->type = CMD_ERRNO;
ec->cstat->val = EIO; ec->cstat->val = EIO;
sudo_debug_printf(SUDO_DEBUG_ERROR, sudo_debug_printf(SUDO_DEBUG_ERROR,