]> granicus.if.org Git - sudo/commitdiff
Ignore SIGTTIN and SIGTTOU in main sudo process when I/O logging.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 May 2012 18:21:07 +0000 (14:21 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 23 May 2012 18:21:07 +0000 (14:21 -0400)
It is better to receive EIO from read()/write() than to be suspended
when we don't expect it.  Fixes a problem when our terminal is
revoked which can happen when, e.g. our sshd is killed unceremoniously.
Also, only change the value of "alive" from true to false, never
from false to true.  It is possible for us to receive notification
of the child having stopped after it is already dead.  This does
not mean it has risen from the grave.

--HG--
branch : 1.7

exec_pty.c

index b0bc8f0bbdda9c041fc6eaffa350f6d355f31b22..d1111fc1a6e40b8ed9a704e53a18de408c93c37b 100644 (file)
@@ -432,6 +432,11 @@ fork_pty(path, argv, envp, sv, rbac_enabled, bgmode, maxfd)
     sa.sa_handler = handler;
     sigaction(SIGTSTP, &sa, NULL);
 
+    /* We don't want to receive SIGTTIN/SIGTTOU, getting EIO is preferable. */
+    sa.sa_handler = SIG_IGN;
+    sigaction(SIGTTIN, &sa, NULL);
+    sigaction(SIGTTOU, &sa, NULL);
+
     if (foreground) {
        /* Copy terminal attrs from user tty -> pty slave. */
        if (term_copy(io_fds[SFD_USERTTY], io_fds[SFD_SLAVE])) {
@@ -857,10 +862,12 @@ exec_monitor(path, argv, envp, backchannel, rbac)
             * Handle SIGCHLD specially and deliver other signals
             * directly to the child.
             */
-           if (signo == SIGCHLD)
-               alive = handle_sigchld(backchannel, &cstat);
-           else
+           if (signo == SIGCHLD) {
+               if (!handle_sigchld(backchannel, &cstat))
+                   alive = FALSE;
+           } else {
                deliver_signal(child, signo);
+           }
            continue;
        }
        if (errpipe[0] != -1 && FD_ISSET(errpipe[0], fdsr)) {