From: Mike Yuan Date: Tue, 8 Apr 2025 14:43:28 +0000 (+0200) Subject: core/exec-invoke: never override acquired user cred with fallback one X-Git-Tag: v258-rc1~854^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fb438cc88826399f39305765a7881cbf63b5e49;p=thirdparty%2Fsystemd.git core/exec-invoke: never override acquired user cred with fallback one --- diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 7e2cdd8c46c..1c01a466159 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -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,