2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Don't kill the parent process group on suspend if it is not sudo's pid.

If sudo is not the process group leader we must only send the suspend
signal to sudo itself.  When sudo is run via a shell script, it
usually has the same process group as the shell script interpreter.
We do not want to suspend the script itself when the command run
by sudo is suspended.
This commit is contained in:
Todd C. Miller
2022-11-07 14:51:43 -07:00
parent bbe4fbaaae
commit f87fac3b55

View File

@@ -225,8 +225,13 @@ suspend_sudo_pty(struct exec_closure *ec, int signo)
sudo_warn(U_("unable to set handler for signal %d"), signo);
}
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s", signame);
if (killpg(ec->ppgrp, signo) != 0)
sudo_warn("killpg(%d, SIG%s)", (int)ec->ppgrp, signame);
if (ec->ppgrp == ec->sudo_pid) {
if (killpg(ec->ppgrp, signo) != 0)
sudo_warn("killpg(%d, SIG%s)", (int)ec->ppgrp, signame);
} else {
if (kill(ec->sudo_pid, signo) != 0)
sudo_warn("kill(%d, SIG%s)", (int)ec->sudo_pid, signame);
}
/* Log the resume event. */
log_suspend(ec, SIGCONT);