blob: 33ef451f2a98eede8c480f194282d2a9a8322f0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# Tests for configuration directory and file precedences
#
set -eux
rm -f /{usr/lib,etc}/tmpfiles.d/{L,w}-*.conf
rm -fr /tmp/precedence/{L,w}
mkdir -p /{usr/lib,etc}/tmpfiles.d
mkdir -p /tmp/precedence/{L,w}
#
# 'L'
#
ln -s /dev/null /tmp/precedence/L
# Overwrite the existing symlink
cat >/usr/lib/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-z.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-z.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-z.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-z.conf"
# /usr/…/L-a.conf has higher prio than /etc/…/L-z.conf
cat >/usr/lib/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /usr/lib/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/usr/lib/tmpfiles.d/L-a.conf"
# Files in /etc should override those in /usr
cat >/etc/tmpfiles.d/L-a.conf<<EOF
L+ /tmp/precedence/L - - - - /etc/tmpfiles.d/L-a.conf
EOF
systemd-tmpfiles --create
test "$(readlink /tmp/precedence/L)" = "/etc/tmpfiles.d/L-a.conf"
#
# 'w'
#
touch /tmp/precedence/w/f
# Multiple configuration files specifying 'w+' for the same path is allowed.
for i in a c; do
cat >/usr/lib/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-$i.conf\n
EOF
cat >/etc/tmpfiles.d/w-$i.conf<<EOF
w+ /tmp/precedence/w/f - - - - /etc/tmpfiles.d/w-$i.conf\n
EOF
done
cat >/usr/lib/tmpfiles.d/w-b.conf<<EOF
w+ /tmp/precedence/w/f - - - - /usr/lib/tmpfiles.d/w-b.conf\n
EOF
systemd-tmpfiles --create
cmp /tmp/precedence/w/f <<EOF
/etc/tmpfiles.d/w-a.conf
/usr/lib/tmpfiles.d/w-b.conf
/etc/tmpfiles.d/w-c.conf
EOF
|