]> git.ipfire.org Git - thirdparty/systemd.git/commit
core/exec-invoke: suppress placeholder home only in build_environment()
authorMike Yuan <me@yhndnzj.com>
Mon, 18 Nov 2024 18:41:07 +0000 (19:41 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 28 Nov 2024 14:08:36 +0000 (15:08 +0100)
commit3808937ff69398bed24767dbf6208075f01b8ed3
tree20d3fb53ea3343485cecc23b7175dffb4f3c7a3d
parente70064370d46b553f70256da029e70201801bf04
core/exec-invoke: suppress placeholder home only in build_environment()

Currently, get_fixed_user() employs USER_CREDS_SUPPRESS_PLACEHOLDER,
meaning home path is set to NULL if it's empty or root. However,
the path is also used for applying WorkingDirectory=~, and we'd
spuriously use the invoking user's home as fallback even if
User= is changed in that case.

Let's instead delegate such suppression to build_environment(),
so that home is proper initialized for usage at other steps.
shell doesn't actually suffer from such problem, but it's changed
too for consistency.

Alternative to #34789

(cherry picked from commit b718b86e1b8477f58461f3c456c944abb1428c0f)
src/core/exec-invoke.c
test/units/TEST-07-PID1.working-directory.sh [new file with mode: 0755]