Files
finit/test/tmpfiles-unsupported.sh
T
Joachim Wiberg 4a11294f98 tmpfiles: skip an entry that is not supported, do not exit
tmpfiles exited at the first entry with a type it does not know, or
with a % specifier in the path:

    h /tmp/dir - - - - +i
    f /tmp/dir/after

    tmpfiles --create t.conf

This never created /tmp/dir/after.  At boot it meant that one such
line, in any tmpfiles.d file, stopped every entry after it, in that
file and in all the files sorted after it.  The message says skipping,
but errx() exits.

Warn and go on with the next entry.  With two passes, for --create
with --remove, only the second one warns.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2026-11-20 18:02:34 +01:00

37 lines
904 B
Bash
Executable File

#!/bin/sh
# Verify that tmpfiles skips an entry it does not support, and goes on
# with the rest
set -eu
TEST_DIR=$(dirname "$0")
DIR=/tmp/unsupported
CONF=/tmp/unsupported.conf
test_teardown()
{
say "Running test teardown."
run "rm -rf $DIR $CONF"
}
# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"
run "cat > $CONF" <<CONF
d $DIR
h $DIR - - - - +i
f $DIR/%m
f $DIR/after
CONF
say 'Create only'
msg=$(texec sh -c "/libexec/finit/tmpfiles --create $CONF 2>&1")
assert "The entry after is created" "$(texec ls $DIR)" = "after"
assert "Each is reported once" "$(echo "$msg" | grep -c skipping)" -eq 2
say 'Remove and create, two passes'
run "rm $DIR/after"
msg=$(texec sh -c "/libexec/finit/tmpfiles --create --remove $CONF 2>&1")
assert "The entry after is created" "$(texec ls $DIR)" = "after"
assert "Each is reported once" "$(echo "$msg" | grep -c skipping)" -eq 2