From: Todd C. Miller Date: Thu, 3 Feb 2011 15:34:33 +0000 (-0500) Subject: Pass SIGUSR1/SIGUSR2 through to the child. X-Git-Tag: SUDO_1_7_5~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6045f19736e6685b9cf9570ac7e998c88cfe5c9f;p=sudo Pass SIGUSR1/SIGUSR2 through to the child. --HG-- branch : 1.7 --- diff --git a/exec.c b/exec.c index 80aac24d5..ea1eba3fa 100644 --- 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]); diff --git a/exec_pty.c b/exec_pty.c index fc225ff82..328fca857 100644 --- a/exec_pty.c +++ b/exec_pty.c @@ -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; } }