utmp: remove /dev from line

utmp(5) says `ut_line` is the device name minus the leading "/dev/". Therefore,
remove it. Without that, when using UtmpMode=user, we get `/dev/tty` in the
output of `last`/`w`.
This commit is contained in:
Vincent Bernat
2021-10-19 09:21:54 +02:00
committed by Lennart Poettering
parent 07721d1380
commit 33331d116d
+6 -2
View File
@@ -4136,13 +4136,17 @@ static int exec_child(
}
}
if (context->utmp_id)
if (context->utmp_id) {
const char *line = context->tty_path ?
(path_startswith(context->tty_path, "/dev/") ?: context->tty_path) :
NULL;
utmp_put_init_process(context->utmp_id, getpid_cached(), getsid(0),
context->tty_path,
line,
context->utmp_mode == EXEC_UTMP_INIT ? INIT_PROCESS :
context->utmp_mode == EXEC_UTMP_LOGIN ? LOGIN_PROCESS :
USER_PROCESS,
username);
}
if (uid_is_valid(uid)) {
r = chown_terminal(STDIN_FILENO, uid);