If we receive a signal from the command we executed, do not forward

it back to the command.  This fixes a problem with BSD-derived
versions of the reboot command which send SIGTERM to all other
processes, including the sudo process.  Sudo would then deliver
SIGTERM to reboot which would die before calling the reboot() system
call, effectively leaving the system in single user mode.
This commit is contained in:
Todd C. Miller
2012-08-06 14:38:35 -04:00
parent d10fb81fe5
commit dc08cf3c99
4 changed files with 178 additions and 50 deletions

View File

@@ -30,18 +30,23 @@
/* exec.c */
int sudo_execve(const char *path, char *const argv[], char *const envp[], int noexec);
int pipe_nonblock(int fds[2]);
extern volatile pid_t cmnd_pid;
/* exec_pty.c */
struct command_details;
struct command_status;
int fork_pty(struct command_details *details, int sv[], int *maxfd);
int fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *oset);
int perform_io(fd_set *fdsr, fd_set *fdsw, struct command_status *cstat);
int suspend_parent(int signo);
void fd_set_iobs(fd_set *fdsr, fd_set *fdsw);
#ifdef SA_SIGINFO
void handler(int s, siginfo_t *info, void *context);
#else
void handler(int s);
#endif
void pty_close(struct command_status *cstat);
void pty_setup(uid_t uid, const char *tty, const char *utmp_user);
void terminate_child(pid_t pid, bool use_pgrp);
void terminate_command(pid_t pid, bool use_pgrp);
extern int signal_pipe[2];
/* utmp.c */