]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Verify default SIGCHLD handling. 456/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 23 Oct 2021 13:36:00 +0000 (15:36 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 15 Dec 2021 10:26:51 +0000 (11:26 +0100)
The SIGCHLD handler could have been ignored by parent process.
Make sure that we have default handling activated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/su.c

index 02c5b0be9c04f56fc9a8dc3061f7511651957fbd..58882caf0fbbf9a4b83e0a56175b2c48414333f7 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -295,6 +295,21 @@ static void prepare_pam_close_session (void)
        sigset_t ourset;
        int status;
        int ret;
+       struct sigaction action;
+
+       /* reset SIGCHLD handling to default */
+       action.sa_handler = SIG_DFL;
+       sigemptyset (&action.sa_mask);
+       action.sa_flags = 0;
+       if (0 == caught && sigaction (SIGCHLD, &action, NULL) != 0) {
+               fprintf (stderr,
+                        _("%s: signal masking malfunction\n"),
+                        Prog);
+               SYSLOG ((LOG_WARN, "Will not execute %s", shellstr));
+               closelog ();
+               exit (1);
+               /* Only the child returns. See above. */
+       }
 
        pid_child = fork ();
        if (pid_child == 0) {   /* child shell */
@@ -318,11 +333,7 @@ static void prepare_pam_close_session (void)
                caught = SIGTERM;
        }
        if (0 == caught) {
-               struct sigaction action;
-
                action.sa_handler = catch_signals;
-               sigemptyset (&action.sa_mask);
-               action.sa_flags = 0;
                sigemptyset (&ourset);
 
                if (   (sigaddset (&ourset, SIGTERM) != 0)