From 9195f3807dfaa2062bcb8f79c61efc1e1f6dba46 Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Thu, 10 Jul 2025 18:12:29 +0200 Subject: [PATCH] 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 --- lib/utmp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) -- 2.47.2