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