]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-22-TMPFILES/test-08.sh
Merge pull request #12577 from yuwata/test-network-issue-12344
[thirdparty/systemd.git] / test / TEST-22-TMPFILES / test-08.sh
CommitLineData
8595c458
DM
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
10set -e
11
12rm -fr /tmp/root /tmp/user
13mkdir -p /tmp/root /tmp/user/root
14chown daemon:daemon /tmp/user
15
16# Verify the command works as expected with no prefix or a root-owned prefix.
17echo 'd /tmp/root/test1' | systemd-tmpfiles --create -
18test -d /tmp/root/test1
19echo 'd /test2' | systemd-tmpfiles --root=/tmp/root --create -
20test -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.
31echo 'd /test' | systemd-tmpfiles --root=/tmp/user/root --create -
32test -d /tmp/user/root/test