]> granicus.if.org Git - sudo/commitdiff
To avoid overwriting existing command status, check for CMD_INVALID
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 18 May 2017 19:53:15 +0000 (13:53 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 18 May 2017 19:53:15 +0000 (13:53 -0600)
instead of CMD_ERRNO or CMD_WSTATUS.

src/exec_monitor.c
src/exec_nopty.c
src/exec_pty.c

index 6d28a296c5c45ee5df6a1f96fe9f784dfdba2aa5..c52833eddbd4298f02dd6f0bcb145f06ca1e8b32 100644 (file)
@@ -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.
         */
index 3c14c46e8024abacf3398a65ffe41c347d609220..77362eaa0f6c5c2322c77375a4dc9b82b73d5693 100644 (file)
@@ -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;
        }
index e075a508be4fe92fe8f1e9c6cf303442f8c13f3c..4d4811bf41336a769854c556681ce2ff7ffa54ad 100644 (file)
@@ -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,