]> granicus.if.org Git - sudo/commitdiff
Pass SIGUSR1/SIGUSR2 through to the child.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 3 Feb 2011 15:25:42 +0000 (10:25 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 3 Feb 2011 15:25:42 +0000 (10:25 -0500)
src/exec.c
src/exec_pty.c

index 7aeae2d237ce368a25b2d5e0babc5c5b68159c33..ec4aa390652c7e46fa605505dec5ae81b49964dd 100644 (file)
@@ -160,8 +160,6 @@ static struct signal_state {
     { SIGPIPE },
     { SIGQUIT },
     { SIGTERM },
-    { SIGQUIT },
-    { SIGTERM },
     { SIGTSTP },
     { SIGTTIN },
     { SIGTTOU },
@@ -254,7 +252,10 @@ sudo_execve(struct command_details *details, char *argv[], char *envp[],
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
 
-    /* Note: HP-UX select() will not be interrupted if SA_RESTART set */
+    /*
+     * Signals for forward to the child process (excluding SIGALRM and SIGCHLD).
+     * Note: HP-UX select() will not be interrupted if SA_RESTART set.
+     */
     sa.sa_flags = SA_INTERRUPT; /* do not restart syscalls */
     sa.sa_handler = handler;
     sigaction(SIGALRM, &sa, NULL);
@@ -264,6 +265,8 @@ sudo_execve(struct command_details *details, char *argv[], char *envp[],
     sigaction(SIGPIPE, &sa, NULL);
     sigaction(SIGQUIT, &sa, NULL);
     sigaction(SIGTERM, &sa, NULL);
+    sigaction(SIGUSR1, &sa, NULL);
+    sigaction(SIGUSR2, &sa, NULL);
 
     /* Max fd we will be selecting on. */
     maxfd = MAX(sv[0], signal_pipe[0]);
index 1b6427cc1a95a507523e1b498325641b0cfa7336..75410e3c0e59c0e9292c12de40aad3c726904275 100644 (file)
@@ -695,37 +695,29 @@ deliver_signal(pid_t pid, int signo)
     /* Handle signal from parent. */
     sudo_debug(8, "signal %d from parent", signo);
     switch (signo) {
-    case SIGKILL:
-       _exit(1); /* XXX */
-       /* NOTREACHED */
-    case SIGPIPE:
-    case SIGHUP:
-    case SIGTERM:
-    case SIGINT:
-    case SIGQUIT:
-    case SIGTSTP:
-       /* relay signal to child */
-       killpg(pid, signo);
-       break;
     case SIGALRM:
        terminate_child(pid, TRUE);
        break;
     case SIGCONT_FG:
-       /* foreground process, grant it controlling tty. */
+       /* Continue in foreground, grant it controlling tty. */
        do {
            status = tcsetpgrp(io_fds[SFD_SLAVE], pid);
        } while (status == -1 && errno == EINTR);
        killpg(pid, SIGCONT);
        break;
     case SIGCONT_BG:
-       /* background process, I take controlling tty. */
+       /* Continue in background, I take controlling tty. */
        do {
            status = tcsetpgrp(io_fds[SFD_SLAVE], getpid());
        } while (status == -1 && errno == EINTR);
        killpg(pid, SIGCONT);
        break;
+    case SIGKILL:
+       _exit(1); /* XXX */
+       /* NOTREACHED */
     default:
-       warningx("unexpected signal from child: %d", signo);
+       /* Relay signal to child. */
+       killpg(pid, signo);
        break;
     }
 }