1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
systemd/test/TEST-22-TMPFILES/test-05.sh
Franck Bui 4dc7bfdf4f tmpfiles: use fd_get_path() even less excessively
A follow-up for commit 9d874aec45.

This patch makes "path" parameter mandatory in fd_set_*() helpers removing the
need to use fd_get_path() when NULL was passed. The caller is supposed to pass
the fd anyway so assuming that it also knows the path should be safe.

Actually, the only case where this was useful (or used) was when we were
walking through directory trees (in item_do()). But even in those cases the
paths could be constructed trivially, which is still better than relying on
fd_get_path() (which is an ugly API).

A very succinct test case is also added for 'z/Z' operators so the code dealing
with recursive operators is tested minimally.
2018-08-21 19:48:08 +02:00

46 lines
1.0 KiB
Bash
Executable File

#! /bin/bash
set -e
set -x
rm -fr /tmp/{z,Z}
mkdir /tmp/{z,Z}
#
# 'z'
#
mkdir /tmp/z/d{1,2}
touch /tmp/z/f1 /tmp/z/d1/f11 /tmp/z/d2/f21
systemd-tmpfiles --create - <<EOF
z /tmp/z/f1 0755 daemon daemon - -
z /tmp/z/d1 0755 daemon daemon - -
EOF
test $(stat -c %U:%G /tmp/z/f1) = "daemon:daemon"
test $(stat -c %U:%G /tmp/z/d1) = "daemon:daemon"
test $(stat -c %U:%G /tmp/z/d1/f11) = "root:root"
systemd-tmpfiles --create - <<EOF
z /tmp/z/d2/* 0755 daemon daemon - -
EOF
test $(stat -c %U:%G /tmp/z/d2/f21) = "daemon:daemon"
#
# 'Z'
#
mkdir /tmp/Z/d1 /tmp/Z/d1/d11
touch /tmp/Z/f1 /tmp/Z/d1/f11 /tmp/Z/d1/d11/f111
systemd-tmpfiles --create - <<EOF
Z /tmp/Z/f1 0755 daemon daemon - -
Z /tmp/Z/d1 0755 daemon daemon - -
EOF
test $(stat -c %U:%G /tmp/Z/f1) = "daemon:daemon"
test $(stat -c %U:%G /tmp/Z/d1) = "daemon:daemon"
test $(stat -c %U:%G /tmp/Z/d1/d11) = "daemon:daemon"
test $(stat -c %U:%G /tmp/Z/d1/f11) = "daemon:daemon"
test $(stat -c %U:%G /tmp/Z/d1/d11/f111) = "daemon:daemon"