]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
exit in case of failure.
authorNicolas François <nicolas.francois@centraliens.net>
Mon, 19 Aug 2013 20:58:45 +0000 (22:58 +0200)
committerNicolas François <nicolas.francois@centraliens.net>
Mon, 19 Aug 2013 20:58:45 +0000 (22:58 +0200)
* src/su.c: Fail if the process group leader or the controlling
terminal cannot be set.

ChangeLog
src/su.c

index df00cfdc8a46ef80cd5af135f318ef57789c7e8e..4bbc9b8e01b4a3b74e864403f2a1691177011e87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-19  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/su.c: Fail if the process group leader or the controlling
+       terminal cannot be set.
+
 2013-08-19  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/su.c: Check dup2 return values.
index 67ba1bcb7bdad1a6bccae3571bb1351284f86dae..5c5aec833237877fbc6b8c205ba2660f76c02b5b 100644 (file)
--- 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 */