mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-05 08:45:28 +00:00
Linux sets si_pid in struct siginfo to 0 when the process that sent
the signal is in a different container since the PID namespaces in different conatiners are separate. Avoid looking up the process group by id when si_pid is 0 since getpgid(0) returns the process group of the current process. Since sudo ignores signals sent by processes in its own process group, this had the effect of ignoring signals sent from other containers. From Maarten de Vries
This commit is contained in:
14
src/exec.c
14
src/exec.c
@@ -887,7 +887,7 @@ handler(int s, siginfo_t *info, void *context)
|
||||
* kill itself. For example, this can happen with some versions of
|
||||
* reboot that call kill(-1, SIGTERM) to kill all other processes.
|
||||
*/
|
||||
if (s != SIGCHLD && USER_SIGNALED(info)) {
|
||||
if (s != SIGCHLD && USER_SIGNALED(info) && info->si_pid != 0) {
|
||||
pid_t si_pgrp = getpgid(info->si_pid);
|
||||
if (si_pgrp != (pid_t)-1) {
|
||||
if (si_pgrp == ppgrp || si_pgrp == cmnd_pid)
|
||||
@@ -934,7 +934,6 @@ static void
|
||||
handler_user_only(int s, siginfo_t *info, void *context)
|
||||
{
|
||||
unsigned char signo = (unsigned char)s;
|
||||
pid_t si_pgrp;
|
||||
|
||||
/*
|
||||
* Only forward user-generated signals not sent by a process in
|
||||
@@ -945,11 +944,14 @@ handler_user_only(int s, siginfo_t *info, void *context)
|
||||
*/
|
||||
if (!USER_SIGNALED(info))
|
||||
return;
|
||||
if ((si_pgrp = getpgid(info->si_pid)) != (pid_t)-1) {
|
||||
if (si_pgrp == ppgrp || si_pgrp == cmnd_pid)
|
||||
return;
|
||||
} else if (info->si_pid == cmnd_pid) {
|
||||
if (info->si_pid != 0) {
|
||||
pid_t si_pgrp = getpgid(info->si_pid);
|
||||
if (si_pgrp != (pid_t)-1) {
|
||||
if (si_pgrp == ppgrp || si_pgrp == cmnd_pid)
|
||||
return;
|
||||
} else if (info->si_pid == cmnd_pid) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user