]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
newgrp/useradd: always set SIGCHLD to default
authorSamanta Navarro <ferivoz@riseup.net>
Wed, 26 Apr 2023 11:59:51 +0000 (11:59 +0000)
committerSerge Hallyn <serge@hallyn.com>
Wed, 26 Apr 2023 13:27:45 +0000 (08:27 -0500)
The tools newgrp and useradd expect waitpid to behave as described in
its manual page. But the notes indicate that if SIGCHLD is ignored,
waitpid behaves differently.

A user could set SIGCHLD to ignore before starting newgrp through exec.
Children of newgrp would not become zombies and their PIDs could be
reassigned before newgrp could call kill with the child pid and SIGCONT.

The useradd tool is not installed setuid, but I have added the default
there as well (copied from vipw).

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
src/newgrp.c
src/useradd.c

index f8387f11cbe4bc145ccc04ba9f73b113b9312a89..0bcf31bad62df724428804b7082197bc8b2ec2e1 100644 (file)
@@ -288,6 +288,9 @@ static void syslog_sg (const char *name, const char *group)
                (void) signal (SIGTSTP, SIG_IGN);
                (void) signal (SIGTTIN, SIG_IGN);
                (void) signal (SIGTTOU, SIG_IGN);
+               /* set SIGCHLD to default for waitpid */
+               (void) signal(SIGCHLD, SIG_DFL);
+
                child = fork ();
                if ((pid_t)-1 == child) {
                        /* error in fork() */
index 152b4e53507a4d7b145129b5e08c434082dee57e..e3123615547f51c6fcb6c1048a4cadaeea4770e7 100644 (file)
@@ -20,6 +20,7 @@
 #include <lastlog.h>
 #include <libgen.h>
 #include <pwd.h>
+#include <signal.h>
 #ifdef ACCT_TOOLS_SETUID
 #ifdef USE_PAM
 #include "pam_defs.h"
@@ -2156,6 +2157,9 @@ static void tallylog_reset (const char *user_name)
        if (access(pam_tally2, X_OK) == -1)
                return;
 
+       /* set SIGCHLD to default for waitpid */
+       signal(SIGCHLD, SIG_DFL);
+
        failed = 0;
        switch (childpid = fork())
        {