From 77df77b863b35aa00a5b8e3d63e4dfb094b0aef9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 20:51:16 +0200 Subject: Adding upstream version 252.23. Signed-off-by: Daniel Baumann --- src/core/execute.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/core/execute.c') diff --git a/src/core/execute.c b/src/core/execute.c index 9715d02..2c1dda1 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -4512,6 +4512,16 @@ static int exec_child( } if (context->utmp_id) { + _cleanup_free_ char *username_alloc = NULL; + + if (!username && context->utmp_mode == EXEC_UTMP_USER) { + username_alloc = uid_to_name(uid_is_valid(uid) ? uid : saved_uid); + if (!username_alloc) { + *exit_status = EXIT_USER; + return log_oom(); + } + } + const char *line = context->tty_path ? (path_startswith(context->tty_path, "/dev/") ?: context->tty_path) : NULL; @@ -4520,7 +4530,7 @@ static int exec_child( context->utmp_mode == EXEC_UTMP_INIT ? INIT_PROCESS : context->utmp_mode == EXEC_UTMP_LOGIN ? LOGIN_PROCESS : USER_PROCESS, - username); + username ?: username_alloc); } if (uid_is_valid(uid)) { -- cgit v1.2.3