]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/login.c: Fix checking whether 'login' is started as 'init'
authorEvgeny Grin (Karlson2k) <k2k@drgrin.dev>
Mon, 14 Jul 2025 20:08:32 +0000 (22:08 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Fri, 18 Jul 2025 19:55:10 +0000 (21:55 +0200)
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) <k2k@drgrin.dev>
src/login.c

index 3238c46f3296b5471757f5dbac1a599acc97c0fd..ce2076dec83bd1842b268bbca853ffe77c52236a 100644 (file)
@@ -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);