Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 <tobias@stoeckmann.org>
  • Loading branch information
stoeckmann committed Dec 15, 2021
1 parent f2e8294 commit c0e4ccd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/su.c
Expand Up @@ -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 */
Expand All @@ -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)
Expand Down

0 comments on commit c0e4ccd

Please sign in to comment.