]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/units/testsuite-22.08.sh
resolved: reply using unicast mDNS when appropriate
[thirdparty/systemd.git] / test / units / testsuite-22.08.sh
1 #! /bin/bash
2 #
3 # Verify tmpfiles can run in a root directory under a path prefix that contains
4 # directories owned by unprivileged users, for example when a root file system
5 # is mounted in a regular user's home directory.
6 #
7 # https://github.com/systemd/systemd/pull/11820
8 #
9
10 set -e
11
12 rm -fr /tmp/root /tmp/user
13 mkdir -p /tmp/root /tmp/user/root
14 chown daemon:daemon /tmp/user
15
16 # Verify the command works as expected with no prefix or a root-owned prefix.
17 echo 'd /tmp/root/test1' | systemd-tmpfiles --create -
18 test -d /tmp/root/test1
19 echo 'd /test2' | systemd-tmpfiles --root=/tmp/root --create -
20 test -d /tmp/root/test2
21
22 # Verify the command fails to write to a root-owned subdirectory under an
23 # unprivileged user's directory when it's not part of the prefix, as expected
24 # by the unsafe_transition function.
25 ! echo 'd /tmp/user/root/test' | systemd-tmpfiles --create -
26 ! test -e /tmp/user/root/test
27 ! echo 'd /user/root/test' | systemd-tmpfiles --root=/tmp --create -
28 ! test -e /tmp/user/root/test
29
30 # Verify the above works when all user-owned directories are in the prefix.
31 echo 'd /test' | systemd-tmpfiles --root=/tmp/user/root --create -
32 test -d /tmp/user/root/test