1#! /bin/bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3set -eux
4set -o pipefail
5
6rm -fr /tmp/{z,Z}
7mkdir  /tmp/{z,Z}
8
9#
10# 'z'
11#
12mkdir /tmp/z/d{1,2}
13touch /tmp/z/f1 /tmp/z/d1/f11 /tmp/z/d2/f21
14
15systemd-tmpfiles --create - <<EOF
16z     /tmp/z/f1    0755 daemon daemon - -
17z     /tmp/z/d1    0755 daemon daemon - -
18EOF
19
20test "$(stat -c %U:%G /tmp/z/f1)" = "daemon:daemon"
21test "$(stat -c %U:%G /tmp/z/d1)" = "daemon:daemon"
22test "$(stat -c %U:%G /tmp/z/d1/f11)" = "root:root"
23
24systemd-tmpfiles --create - <<EOF
25z     /tmp/z/d2/*    0755 daemon daemon - -
26EOF
27
28test "$(stat -c %U:%G /tmp/z/d2/f21)" = "daemon:daemon"
29
30#
31# 'Z'
32#
33mkdir /tmp/Z/d1 /tmp/Z/d1/d11
34touch /tmp/Z/f1 /tmp/Z/d1/f11 /tmp/Z/d1/d11/f111
35
36systemd-tmpfiles --create - <<EOF
37Z     /tmp/Z/f1    0755 daemon daemon - -
38Z     /tmp/Z/d1    0755 daemon daemon - -
39EOF
40
41test "$(stat -c %U:%G /tmp/Z/f1)" = "daemon:daemon"
42test "$(stat -c %U:%G /tmp/Z/d1)" = "daemon:daemon"
43test "$(stat -c %U:%G /tmp/Z/d1/d11)" = "daemon:daemon"
44test "$(stat -c %U:%G /tmp/Z/d1/f11)" = "daemon:daemon"
45test "$(stat -c %U:%G /tmp/Z/d1/d11/f111)" = "daemon:daemon"
46