summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-11-20 09:34:25 +0100
committerGitHub <noreply@github.com>2024-11-20 09:34:25 +0100
commit52b0351a154e9ad3f6a62c5de61198e454d86ecb (patch)
tree9f55b655cac07ab41ebe5d744ae5464c8ea748b3 /test
parentunits: add initrd directory to list of conditions for systemd-confext (diff)
parentcore/exec-invoke: suppress placeholder home only in build_environment() (diff)
downloadsystemd-52b0351a154e9ad3f6a62c5de61198e454d86ecb.tar.xz
systemd-52b0351a154e9ad3f6a62c5de61198e454d86ecb.zip
core/exec-invoke: suppress placeholder home only in build_environment() (#35219)
Alternative to https://github.com/systemd/systemd/pull/34789 Closes #34789
Diffstat (limited to 'test')
-rwxr-xr-xtest/units/TEST-07-PID1.working-directory.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/units/TEST-07-PID1.working-directory.sh b/test/units/TEST-07-PID1.working-directory.sh
new file mode 100755
index 0000000000..1cff3e0602
--- /dev/null
+++ b/test/units/TEST-07-PID1.working-directory.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+(! systemd-run --wait -p DynamicUser=yes \
+ -p EnvironmentFile=-/usr/lib/systemd/systemd-asan-env \
+ -p WorkingDirectory='~' true)
+
+assert_eq "$(systemd-run --pipe --uid=root -p WorkingDirectory='~' pwd)" "/root"
+assert_eq "$(systemd-run --pipe --uid=nobody -p WorkingDirectory='~' pwd)" "/"
+assert_eq "$(systemd-run --pipe --uid=testuser -p WorkingDirectory='~' pwd)" "/home/testuser"
+
+(! systemd-run --wait -p DynamicUser=yes -p User=testuser \
+ -p EnvironmentFile=-/usr/lib/systemd/systemd-asan-env \
+ -p WorkingDirectory='~' true)