]> git.ipfire.org Git - thirdparty/systemd.git/commit - man/systemd.exec.xml
core/execute: always set $USER and introduce SetLoginEnvironment= 29493/head
authorMike Yuan <me@yhndnzj.com>
Sat, 7 Oct 2023 12:08:21 +0000 (20:08 +0800)
committerMike Yuan <me@yhndnzj.com>
Mon, 9 Oct 2023 16:00:26 +0000 (00:00 +0800)
commit854eca4a95993bb1bd77a18de39efe1ed1a44bbd
treeac906198eadde7d96b58d03ee352cfdb00188431
parent1c9433559a40982785011aa187e2b34420a67e7e
core/execute: always set $USER and introduce SetLoginEnvironment=

Before this commit, $USER, $HOME, $LOGNAME and $SHELL are only
set when User= is set for the unit. For system service, this
results in different behaviors depending on whether User=root is set.

$USER always makes sense on its own, so let's set it unconditionally.
Ideally $HOME should be set too, but it causes trouble when e.g. getty
passes '-p' to login(1), which then doesn't override $HOME. $LOGNAME and
$SHELL are more like "login environments", and are generally not
suitable for system services. Therefore, a new option SetLoginEnvironment=
is also added to control the latter three variables.

Fixes #23438

Replaces #8227
man/org.freedesktop.systemd1.xml
man/systemd.exec.xml
src/core/dbus-execute.c
src/core/execute.c
src/core/execute.h
src/core/load-fragment-gperf.gperf.in
src/shared/bus-unit-util.c