From: Nicolas François Date: Mon, 19 Aug 2013 20:58:45 +0000 (+0200) Subject: exit in case of failure. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6a1e97c4b9b5ddc9730cead9b0ff28346cec945;p=thirdparty%2Fshadow.git exit in case of failure. * src/su.c: Fail if the process group leader or the controlling terminal cannot be set. --- diff --git a/ChangeLog b/ChangeLog index df00cfdc8..4bbc9b8e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-19 Nicolas François + + * src/su.c: Fail if the process group leader or the controlling + terminal cannot be set. + 2013-08-19 Nicolas François * src/su.c: Check dup2 return values. diff --git a/src/su.c b/src/su.c index 67ba1bcb7..5c5aec833 100644 --- a/src/su.c +++ b/src/su.c @@ -364,11 +364,19 @@ static void handle_session (void) && STDERR_FILENO != fd_pts) close (fd_pts); - if (setsid() == -1) - fprintf (stderr, _("%s: Cannot set process group leader\n"), Prog); - else - if (ioctl (STDIN_FILENO, TIOCSCTTY, 1) == -1) - fprintf (stderr, _("%s: Cannot set controlling terminal\n"), Prog); + if (setsid() == -1) { + fprintf (stderr, + _("%s: Cannot set process group leader\n"), + Prog); + exit (1); + } + + if (ioctl (STDIN_FILENO, TIOCSCTTY, 1) == -1) { + fprintf (stderr, + _("%s: Cannot set controlling terminal\n"), + Prog); + exit (1); + } } return; /* Only the child will return from pam_create_session */