From: Vincent Bernat Date: Mon, 18 Oct 2021 18:58:43 +0000 (+0200) Subject: utmp: remove /dev from line X-Git-Tag: v250-rc1~477 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33331d116db2eaf1189ea56ee4b36540179ac3dd;p=thirdparty%2Fsystemd.git 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`. --- diff --git a/src/core/execute.c b/src/core/execute.c index e1f8d9a31b8..9d100889018 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -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);