If started as init, login and sulogin need to start a new session.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user