core/exec-invoke: never override acquired user cred with fallback one

This commit is contained in:
Mike Yuan
2025-04-09 19:30:17 +02:00
parent ba7fb8cf5f
commit 2fb438cc88
+3 -1
View File
@@ -1973,7 +1973,9 @@ static int build_environment(
* could cause problem for e.g. getty, since login doesn't override $HOME, and $LOGNAME and $SHELL don't
* really make much sense since we're not logged in. Hence we conditionalize the three based on
* SetLoginEnvironment= switch. */
if (!c->user && !c->dynamic_user && p->runtime_scope == RUNTIME_SCOPE_SYSTEM) {
if (!username && !c->dynamic_user && p->runtime_scope == RUNTIME_SCOPE_SYSTEM) {
assert(!c->user);
r = get_fixed_user("root", &username, NULL, NULL, &home, &shell);
if (r < 0)
return log_exec_debug_errno(c,