]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: Verify default SIGCHLD handling.
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sat, 23 Oct 2021 11:44:23 +0000 (13:44 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Dec 2021 14:01:15 +0000 (15:01 +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>
login-utils/su-common.c

index 06282d21a1b313c97d56d96eb6b938d30d30be2a..e57ff64bdb60977e3cad3dd316d1812cee3bb54c 100644 (file)
@@ -522,6 +522,7 @@ static void parent_setup_signals(struct su_context *su)
 
 static void create_watching_parent(struct su_context *su)
 {
+       struct sigaction action;
        int status;
 
        DBG(MISC, ul_debug("forking..."));
@@ -545,6 +546,19 @@ static void create_watching_parent(struct su_context *su)
 #endif
        fflush(stdout);                 /* ??? */
 
+       /* set default handler for SIGCHLD */
+       sigemptyset(&action.sa_mask);
+       action.sa_flags = 0;
+       action.sa_handler = SIG_DFL;
+       if (sigaction(SIGCHLD, &action, NULL)) {
+               supam_cleanup(su, PAM_ABORT);
+#ifdef USE_PTY
+               if (su->force_pty)
+                       ul_pty_cleanup(su->pty);
+#endif
+               err(EXIT_FAILURE, _("cannot set child signal handler"));
+       }
+
        switch ((int) (su->child = fork())) {
        case -1: /* error */
                supam_cleanup(su, PAM_ABORT);