2020-03-04 12:35:06 +03:00
#!/usr/bin/env bash
2021-04-09 20:39:41 +03:00
set -eux
2019-06-25 11:40:16 +03:00
set -o pipefail
systemd-analyze log-level debug
systemd-analyze log-target console
# Set everything up without DynamicUser=1
systemd-run --wait -p DynamicUser = 0 -p StateDirectory = zzz touch /var/lib/zzz/test
systemd-run --wait -p DynamicUser = 0 -p StateDirectory = zzz test -f /var/lib/zzz/test
2021-04-08 02:27:33 +03:00
systemd-run --wait -p DynamicUser = 0 -p StateDirectory = zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success' ; exit 1; }
2019-06-25 11:40:16 +03:00
test -d /var/lib/zzz
2021-04-08 00:24:25 +03:00
test ! -L /var/lib/zzz
test ! -e /var/lib/private/zzz
2019-06-25 11:40:16 +03:00
test -f /var/lib/zzz/test
2021-04-08 00:24:25 +03:00
test ! -f /var/lib/zzz/test-missing
2019-06-25 11:40:16 +03:00
# Convert to DynamicUser=1
systemd-run --wait -p DynamicUser = 1 -p StateDirectory = zzz test -f /var/lib/zzz/test
2021-04-08 02:27:33 +03:00
systemd-run --wait -p DynamicUser = 1 -p StateDirectory = zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success' ; exit 1; }
2019-06-25 11:40:16 +03:00
test -L /var/lib/zzz
test -d /var/lib/private/zzz
test -f /var/lib/zzz/test
2021-04-08 00:24:25 +03:00
test ! -f /var/lib/zzz/test-missing
2019-06-25 11:40:16 +03:00
# Convert back
systemd-run --wait -p DynamicUser = 0 -p StateDirectory = zzz test -f /var/lib/zzz/test
2021-04-08 02:27:33 +03:00
systemd-run --wait -p DynamicUser = 0 -p StateDirectory = zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success' ; exit 1; }
2019-06-25 11:40:16 +03:00
test -d /var/lib/zzz
2021-04-08 00:24:25 +03:00
test ! -L /var/lib/zzz
test ! -e /var/lib/private/zzz
2019-06-25 11:40:16 +03:00
test -f /var/lib/zzz/test
2021-04-08 00:24:25 +03:00
test ! -f /var/lib/zzz/test-missing
2019-06-25 11:40:16 +03:00
systemd-analyze log-level info
2021-04-08 01:09:55 +03:00
echo OK >/testok
2019-06-25 11:40:16 +03:00
exit 0