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