From: Tobias Stoeckmann Date: Sat, 23 Oct 2021 11:44:23 +0000 (+0200) Subject: su: Verify default SIGCHLD handling. X-Git-Tag: v2.38-rc1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=312b64d9d1cedeac8d926cc503ffb4fbe023ade0;p=thirdparty%2Futil-linux.git su: Verify default SIGCHLD handling. The SIGCHLD handler could have been ignored by parent process. Make sure that we have default handling activated. Signed-off-by: Tobias Stoeckmann --- diff --git a/login-utils/su-common.c b/login-utils/su-common.c index 06282d21a1..e57ff64bdb 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -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);