aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--loginutils/login.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 4e65b3a19..3531d1424 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -341,6 +341,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_LOGIN_SESSION_AS_CHILD
pid_t child_pid;
#endif
+ pid_t my_pid;
INIT_G();
@@ -525,6 +526,9 @@ int login_main(int argc UNUSED_PARAM, char **argv)
if (pw->pw_uid != 0)
die_if_nologin();
+ my_pid = getpid();
+ update_utmp(my_pid, USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
+
#if ENABLE_LOGIN_SESSION_AS_CHILD
child_pid = vfork();
if (child_pid != 0) {
@@ -532,8 +536,8 @@ int login_main(int argc UNUSED_PARAM, char **argv)
bb_simple_perror_msg("vfork");
else {
wait_for_exitstatus(child_pid);
- update_utmp_DEAD_PROCESS(child_pid);
}
+ update_utmp_DEAD_PROCESS(my_pid);
login_pam_end(pamh);
return 0;
}
@@ -546,8 +550,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);