[PATCH]: login does not update UTMP getty entry properly
Joachim Nilsson
troglobit at gmail.com
Mon Aug 12 13:43:15 UTC 2019
When LOGIN_SESSION_AS_CHILD is enabled login.c calls vfork() before
calling update_utmp(). Thie prevents update_utmp() from updating the
entry created by getty, because we use ut_pid (like upstream shadow
login does) to locate the UTMP record.
Signed-off-by: Joachim Nilsson <troglobit at gmail.com>
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -522,6 +522,8 @@ int login_main(int argc UNUSED_PARAM, ch
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) {
@@ -544,8 +546,6 @@ int login_main(int argc UNUSED_PARAM, ch
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);
More information about the busybox
mailing list