mirror of
https://github.com/systemd/systemd.git
synced 2025-01-06 17:18:12 +03:00
b718b86e1b
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
21 lines
779 B
Bash
Executable File
21 lines
779 B
Bash
Executable File
#!/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)
|