]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-22-TMPFILES/test-02.sh
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / test / TEST-22-TMPFILES / test-02.sh
CommitLineData
9f36a8fb
FB
1#! /bin/bash
2#
3# Basic tests for types creating directories
4#
5
6set -e
7set -x
8
55b25c43
RG
9rm -fr /tmp/{C,d,D,e}
10mkdir /tmp/{C,d,D,e}
9f36a8fb
FB
11
12#
13# 'd'
14#
15mkdir /tmp/d/2
16chmod 777 /tmp/d/2
17
18systemd-tmpfiles --create - <<EOF
19d /tmp/d/1 0755 daemon daemon - -
20d /tmp/d/2 0755 daemon daemon - -
21EOF
22
23test -d /tmp/d/1
24test $(stat -c %U:%G:%a /tmp/d/1) = "daemon:daemon:755"
25
26test -d /tmp/d/2
27test $(stat -c %U:%G:%a /tmp/d/2) = "daemon:daemon:755"
28
29#
30# 'D'
31#
32mkdir /tmp/D/2
33chmod 777 /tmp/D/2
34touch /tmp/D/2/foo
35
36systemd-tmpfiles --create - <<EOF
37D /tmp/D/1 0755 daemon daemon - -
38D /tmp/D/2 0755 daemon daemon - -
39EOF
40
41test -d /tmp/D/1
42test $(stat -c %U:%G:%a /tmp/D/1) = "daemon:daemon:755"
43
44test -d /tmp/D/2
45test $(stat -c %U:%G:%a /tmp/D/2) = "daemon:daemon:755"
46
47systemd-tmpfiles --remove - <<EOF
48D /tmp/D/2 0755 daemon daemon - -
49EOF
50
51# the content of '2' should be removed
52test "$(echo /tmp/D/2/*)" = "/tmp/D/2/*"
53
54#
55# 'e'
56#
57mkdir -p /tmp/e/2/{d1,d2}
58chmod 777 /tmp/e/2
59chmod 777 /tmp/e/2/d*
60
61systemd-tmpfiles --create - <<EOF
62e /tmp/e/1 0755 daemon daemon - -
63e /tmp/e/2/* 0755 daemon daemon - -
64EOF
65
66! test -d /tmp/e/1
67
68test -d /tmp/e/2
69test $(stat -c %U:%G:%a /tmp/e/2) = "root:root:777"
70
71test -d /tmp/e/2/d1
72test $(stat -c %U:%G:%a /tmp/e/2/d1) = "daemon:daemon:755"
73test -d /tmp/e/2/d2
74test $(stat -c %U:%G:%a /tmp/e/2/d2) = "daemon:daemon:755"
75
76# 'e' operates on directories only
77mkdir -p /tmp/e/3/{d1,d2}
78chmod 777 /tmp/e/3
79chmod 777 /tmp/e/3/d*
80touch /tmp/e/3/f1
81chmod 644 /tmp/e/3/f1
82
83! systemd-tmpfiles --create - <<EOF
84e /tmp/e/3/* 0755 daemon daemon - -
85EOF
86
87# the directories should have been processed although systemd-tmpfiles failed
88# previously due to the presence of a file.
89test -d /tmp/e/3/d1
90test $(stat -c %U:%G:%a /tmp/e/3/d1) = "daemon:daemon:755"
91test -d /tmp/e/3/d2
92test $(stat -c %U:%G:%a /tmp/e/3/d2) = "daemon:daemon:755"
93
94test -f /tmp/e/3/f1
95test $(stat -c %U:%G:%a /tmp/e/3/f1) = "root:root:644"
55b25c43
RG
96
97#
98# 'C'
99#
100
101mkdir /tmp/C/{1,2,3}-origin
102touch /tmp/C/{1,2,3}-origin/f1
103chmod 755 /tmp/C/{1,2,3}-origin/f1
104
105mkdir /tmp/C/{2,3}
106touch /tmp/C/3/f1
107
108systemd-tmpfiles --create - <<EOF
109C /tmp/C/1 0755 daemon daemon - /tmp/C/1-origin
110C /tmp/C/2 0755 daemon daemon - /tmp/C/2-origin
111EOF
112
113test -d /tmp/C/1
114test $(stat -c %U:%G:%a /tmp/C/1/f1) = "daemon:daemon:755"
115test -d /tmp/C/2
116test $(stat -c %U:%G:%a /tmp/C/2/f1) = "daemon:daemon:755"
117
118! systemd-tmpfiles --create - <<EOF
119C /tmp/C/3 0755 daemon daemon - /tmp/C/3-origin
120EOF
121
122test $(stat -c %U:%G:%a /tmp/C/3/f1) = "root:root:644"