]> 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:34:33 +0000 (10:34 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 3 Feb 2011 15:34:33 +0000 (10:34 -0500)
--HG--
branch : 1.7

exec.c
exec_pty.c

diff --git a/exec.c b/exec.c
index 80aac24d51736d67b31de1cd3bdbf946428c47ad..ea1eba3fae1902bc7dcfac38a9135349bfe0b374 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -167,8 +167,6 @@ static struct signal_state {
     { SIGPIPE },
     { SIGQUIT },
     { SIGTERM },
-    { SIGQUIT },
-    { SIGTERM },
     { SIGTSTP },
     { SIGTTIN },
     { SIGTTOU },
@@ -283,7 +281,10 @@ sudo_execve(path, argv, envp, uid, cstat, dowait, bgmode)
     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(SIGCHLD, &sa, NULL);
@@ -292,6 +293,8 @@ sudo_execve(path, argv, envp, uid, cstat, dowait, bgmode)
     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 fc225ff82797ce9c25ab121cc5bd4e6b95f8ffea..328fca8578d44491c383365c3d1866112bbe3bd8 100644 (file)
@@ -587,37 +587,29 @@ deliver_signal(pid, signo)
 
     /* Handle signal from parent. */
     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 SIGUSR1:
-       /* 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 SIGUSR2:
-       /* 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;
     }
 }