diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 18:51:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 18:51:16 +0000 |
commit | 77df77b863b35aa00a5b8e3d63e4dfb094b0aef9 (patch) | |
tree | 76580546179a403e346084143bd92393474e71be /src/core/execute.c | |
parent | Adding upstream version 252.22. (diff) | |
download | systemd-77df77b863b35aa00a5b8e3d63e4dfb094b0aef9.tar.xz systemd-77df77b863b35aa00a5b8e3d63e4dfb094b0aef9.zip |
Adding upstream version 252.23.upstream/252.23
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/core/execute.c')
-rw-r--r-- | src/core/execute.c | 12 |
1 files changed, 11 insertions, 1 deletions
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)) { |