From: Evgeny Grin (Karlson2k) Date: Thu, 10 Jul 2025 16:12:29 +0000 (+0200) Subject: lib/utmp.c: check parent PID too when looking for utmp entry X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=9195f3807dfaa2062bcb8f79c61efc1e1f6dba46;p=thirdparty%2Fshadow.git lib/utmp.c: check parent PID too when looking for utmp entry 'login' binary may fork itself before this check, so the entry may contain parent PID instead of current process PID --- diff --git a/lib/utmp.c b/lib/utmp.c index ff886354a..44f0301f4 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -157,7 +157,8 @@ get_current_utmp(void) /* First, try to find a valid utmp entry for this process. */ while ((ut = getutxent()) != NULL) { - if ( (ut->ut_pid == getpid ()) + if ( ( (ut->ut_pid == getpid ()) + || (ut->ut_pid == getppid ())) && ('\0' != ut->ut_id[0]) && ( (LOGIN_PROCESS == ut->ut_type) || (USER_PROCESS == ut->ut_type))