(! systemd-run --wait --pipe -p RestrictFileSystems="~proc devtmpfs sysfs" ls /sys)
fi
-if [[ ! -v ASAN_OPTIONS ]]; then
- # Ensure DynamicUser=yes does not imply PrivateTmp=yes if TemporaryFileSystem=/tmp /var/tmp is set
- systemd-run --unit test-07-dynamic-user-tmp.service \
- --service-type=notify \
- -p DynamicUser=yes \
- -p NotifyAccess=all \
- sh -c 'touch /tmp/a && touch /var/tmp/b && ! test -f /tmp/b && ! test -f /var/tmp/a && systemd-notify --ready && sleep infinity'
- (! ls /tmp/systemd-private-"$(tr -d '-' < /proc/sys/kernel/random/boot_id)"-test-07-dynamic-user-tmp.service-* &>/dev/null)
- (! ls /var/tmp/systemd-private-"$(tr -d '-' < /proc/sys/kernel/random/boot_id)"-test-07-dynamic-user-tmp.service-* &>/dev/null)
- systemctl is-active test-07-dynamic-user-tmp.service
- systemctl stop test-07-dynamic-user-tmp.service
-fi
+# Ensure DynamicUser=yes does not imply PrivateTmp=yes if TemporaryFileSystem=/tmp /var/tmp is set
+systemd-run \
+ --unit test-07-dynamic-user-tmp.service \
+ --service-type=notify \
+ -p DynamicUser=yes \
+ -p EnvironmentFile=-/usr/lib/systemd/systemd-asan-env \
+ -p NotifyAccess=all \
+ sh -c 'touch /tmp/a && touch /var/tmp/b && ! test -f /tmp/b && ! test -f /var/tmp/a && systemd-notify --ready && sleep infinity'
+(! ls /tmp/systemd-private-"$(tr -d '-' < /proc/sys/kernel/random/boot_id)"-test-07-dynamic-user-tmp.service-* &>/dev/null)
+(! ls /var/tmp/systemd-private-"$(tr -d '-' < /proc/sys/kernel/random/boot_id)"-test-07-dynamic-user-tmp.service-* &>/dev/null)
+systemctl is-active test-07-dynamic-user-tmp.service
+systemctl stop test-07-dynamic-user-tmp.service
# Make sure we properly (de)serialize various string arrays, including whitespaces
# See: https://github.com/systemd/systemd/issues/31214
touch /tmp/root/foo
chmod +x /tmp/root/foo
(! systemd-run --wait --pipe false)
-(! systemd-run --wait --pipe --unit "test-dynamicuser-fail" -p DynamicUser=yes -p WorkingDirectory=/nonexistent true)
+if [[ ! -v ASAN_OPTIONS ]]; then
+ # Here, -p EnvironmentFile=-/usr/lib/systemd/systemd-asan-env does not work,
+ # as sd-executor loads NSS module and fails before applying the environment:
+ # (true)[660]: test-dynamicuser-fail.service: Changing to the requested working directory failed: No such file or directory
+ # (true)[660]: test-dynamicuser-fail.service: Failed at step CHDIR spawning /usr/bin/true: No such file or directory
+ # TEST-07-PID1.sh[660]: ==660==LeakSanitizer has encountered a fatal error.
+ # TEST-07-PID1.sh[660]: ==660==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
+ # TEST-07-PID1.sh[660]: ==660==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
+ (! systemd-run --wait --pipe --unit "test-dynamicuser-fail" -p DynamicUser=yes -p WorkingDirectory=/nonexistent true)
+fi
(! systemd-run --wait --pipe -p RuntimeDirectory=not-a-directory true)
(! systemd-run --wait --pipe -p RootDirectory=/tmp/root this-shouldnt-exist)
(! systemd-run --wait --pipe -p RootDirectory=/tmp/root /foo)