[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] login: update UTMP before forking
From: Markus Gothe <nietzsche () lysator ! liu ! se>
Date: 2020-05-09 11:33:41
Message-ID: sroelicml1vt6b0mh2dag9c0.1589024021318 () lysator ! liu ! se
[Download RAW message or body]
Nice catch!
//Markus
Sent from my BlackBerry - the most secure mobile device
Original Message
From: troglobit@gmail.com
Sent: May 9, 2020 13:04
To: busybox@busybox.net
Subject: [PATCH] login: update UTMP before forking
/bin/login updates the preliminary UTMP record created by /bin/getty for
$LOGNAME. However, if the PID of login is not the same as getty, then
it will create a new entry. This causes GLIBC getlogin(3) to return the
string 'LOGIN' (set by getty) instead of $LOGNAME. This affects tools
like /usr/bin/logname but also various 3rd party PAM applications.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
---
loginutils/login.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/loginutils/login.c b/loginutils/login.c
index 4e65b3a19..03301b3bd 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -525,6 +525,8 @@ int login_main(int argc UNUSED_PARAM, char **argv)
if (pw->pw_uid != 0)
die_if_nologin();
+ update_utmp(getpid(), USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
+
#if ENABLE_LOGIN_SESSION_AS_CHILD
child_pid = vfork();
if (child_pid != 0) {
@@ -546,8 +548,6 @@ int login_main(int argc UNUSED_PARAM, char **argv)
fchown(0, pw->pw_uid, pw->pw_gid);
fchmod(0, 0600);
- update_utmp(getpid(), USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
-
/* We trust environment only if we run by root */
if (ENABLE_LOGIN_SCRIPTS && run_by_root)
run_login_script(pw, full_tty);
--
2.25.1
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic