From: Evgeny Grin (Karlson2k) Date: Mon, 14 Jul 2025 20:08:32 +0000 (+0200) Subject: src/login.c: Fix checking whether 'login' is started as 'init' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90042ad4341a7676436f4e994255af0b5c49d964;p=thirdparty%2Fshadow.git src/login.c: Fix checking whether 'login' is started as 'init' When PAM is not used, login does not fork itself so its own PID should be checked instead of parent PID. Fixes: b44a6c316d96ab038492c63443156810670d176d (26-12-2007; "If started as init, login and sulogin need to start a new session.") Signed-off-by: Evgeny Grin (Karlson2k) --- diff --git a/src/login.c b/src/login.c index 3238c46f3..ce2076dec 100644 --- a/src/login.c +++ b/src/login.c @@ -1111,7 +1111,7 @@ int main (int argc, char **argv) #endif /* If we were init, we need to start a new session */ - if (getppid() == 1) { + if (1 == initial_pid) { setsid(); if (ioctl(0, TIOCSCTTY, 1) != 0) { fprintf (stderr, _("TIOCSCTTY failed on %s"), tty);