]> granicus.if.org Git - shadow/commitdiff
If started as init, login and sulogin need to start a new session.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Wed, 26 Dec 2007 22:36:54 +0000 (22:36 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Wed, 26 Dec 2007 22:36:54 +0000 (22:36 +0000)
ChangeLog
NEWS
src/login.c
src/sulogin.c

index c4994ab09c363970442e37aa3bf64ac6b5cd2f06..3119ade35914f0ace3d9ad4aa5ae24bcb533163c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-26  Nicolas François  <nicolas.francois@centraliens.net>
+
+       Merge Debian's patch 496_login_init_session
+       * src/login.c, src/sulogin.c: If started as init, start a new session.
+
 2007-12-26  Nicolas François  <nicolas.francois@centraliens.net>
 
        Merge Debian's patch 408_passwd_check_arguments
diff --git a/NEWS b/NEWS
index 6334d05de1365520bdb14470bdb3834dcd2c9290..45e2b9e3f2ae910f685386e6317ce66fc746f662 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ shadow-4.1.0 -> shadow-4.1.1                                         UNRELEASED
     user-, user1-user2).
 - passwd
   * Make sure that no more than one username argument was provided.
+- su
+  * If started as init, start a new session.
+- sulogin
+  * If started as init, start a new session.
 
 shadow-4.0.18.2 -> shadow-4.1.0                                                09-12-2008
 
index 8deb992c0674903aa7020d314df2c4a801cc7dc1..e08f448ca7bc90833a288a0e076705c116d6e940 100644 (file)
@@ -41,6 +41,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include "defines.h"
 #include "faillog.h"
 #include "failure.h"
@@ -1039,6 +1040,12 @@ int main (int argc, char **argv)
        }
        /* child */
 #endif
+       /* If we were init, we need to start a new session */
+       if (getppid() == 1) {
+               setsid();
+               if (ioctl(0, TIOCSCTTY, 1))
+                       fprintf(stderr,_("TIOCSCTTY failed on %s"),tty);
+       }
 
        /* We call set_groups() above because this clobbers pam_groups.so */
 #ifndef USE_PAM
index 692606f367d84b07520e759ffb098d9588ddd4a9..bc1b119d00222b3a258ad2380bc4aba28e85771d 100644 (file)
@@ -35,6 +35,7 @@
 #include <pwd.h>
 #include <signal.h>
 #include <stdio.h>
+#include <sys/ioctl.h>
 #include "defines.h"
 #include "getdef.h"
 #include "prototypes.h"
@@ -142,6 +143,12 @@ static RETSIGTYPE catch_signals (int sig)
 #endif
                exit (1);       /* must be a terminal */
        }
+       /* If we were init, we need to start a new session */
+       if (getppid() == 1) {
+               setsid();
+               if (ioctl(0, TIOCSCTTY, 1))
+                       fprintf(stderr,_("TIOCSCTTY failed"));
+       }
        while (*envp)           /* add inherited environment, */
                addenv (*envp++, NULL); /* some variables change later */