mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
When there is a file where an entry wants a directory, or the other
way around, the entry fails or leaves the path as it is. In
tmpfiles.d(5) an = after the type has the path removed first when it
is of another kind than the entry makes:
d= /var/lib/foo 0755 foo foo
The same goes for the directories above the path, anything else in
place of one is removed. tmpfiles ignores the =.
Remove what does not match before the b, c, d, D, f, F, L, and p
entries, the ones that make a path of one kind.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
64 lines
1.6 KiB
Bash
Executable File
64 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify the = modifier of tmpfiles, what is of another kind than the
|
|
# entry makes is removed first
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/match
|
|
CONF=/tmp/match.conf
|
|
|
|
kind()
|
|
{
|
|
texec stat -c %F "$1"
|
|
}
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "rm -rf $DIR $CONF"
|
|
}
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
setup()
|
|
{
|
|
run "rm -rf $DIR; mkdir -p $DIR/dir/sub $DIR/same; mkfifo $DIR/fifo $DIR/parent; echo old > $DIR/file; echo old > $DIR/keep; echo old > $DIR/link; echo same > $DIR/same/file"
|
|
}
|
|
|
|
conf()
|
|
{
|
|
run "cat > $CONF" <<CONF
|
|
d$1 $DIR/fifo
|
|
f$1 $DIR/dir - - - - new
|
|
d$1 $DIR/file
|
|
f$1 $DIR/parent/file - - - - new
|
|
p$1 $DIR/keep
|
|
L$1 $DIR/link - - - - /dev/null
|
|
d$1 $DIR/same
|
|
f$1 $DIR/same/file
|
|
CONF
|
|
run "/libexec/finit/tmpfiles --create $CONF"
|
|
}
|
|
|
|
setup
|
|
conf ""
|
|
say 'Without = a path of another kind is left alone'
|
|
assert "Pipe for d" "$(kind $DIR/fifo)" = "fifo"
|
|
assert "Directory for f" "$(kind $DIR/dir)" = "directory"
|
|
assert "File for d" "$(kind $DIR/file)" = "regular file"
|
|
assert "Pipe as parent" "$(kind $DIR/parent)" = "fifo"
|
|
|
|
setup
|
|
conf "="
|
|
sep
|
|
say 'With = it is removed, and made anew'
|
|
assert "Pipe for d" "$(kind $DIR/fifo)" = "directory"
|
|
assert "Directory for f" "$(texec cat $DIR/dir)" = "new"
|
|
assert "File for d" "$(kind $DIR/file)" = "directory"
|
|
assert "Pipe as parent" "$(texec cat $DIR/parent/file)" = "new"
|
|
assert "File for p" "$(kind $DIR/keep)" = "fifo"
|
|
assert "File for L" "$(texec readlink $DIR/link)" = "/dev/null"
|
|
assert "Same kind is left alone" "$(texec cat $DIR/same/file)" = "same"
|