mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
A ! after the type marks an entry that is only safe to run at boot.
Finit's own files have them, like this one in x11.conf:
D! /tmp/.X11-unix 1777 root root
tmpfiles ignored the ! and ran these entries on every call, so this
emptied the directory under a running X server:
tmpfiles --remove
Only the character right after the type was looked at, and only for
a +.
Read all the modifiers after the type, in any order, and skip an
entry with ! unless the new --boot option is given. Finit gives it
at boot, together with --remove. Before this the r, R, and D entries
were never run at boot, so "r! /forcefsck" in legacy.conf left the
file in place.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
62 lines
1.3 KiB
Bash
Executable File
62 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify that tmpfiles only runs the boot-only entries, the ones with
|
|
# a ! after the type, at boot or when called with --boot
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/boot
|
|
CONF=/tmp/boot.conf
|
|
|
|
tmpfiles()
|
|
{
|
|
run "/libexec/finit/tmpfiles $* $CONF"
|
|
}
|
|
|
|
assert_exists()
|
|
{
|
|
assert "$1 exists" "$(texec sh -c "test -e $1 && echo yes || echo no")" = "$2"
|
|
}
|
|
|
|
test_teardown()
|
|
{
|
|
say "Running test teardown."
|
|
run "rm -rf $DIR $CONF /fastboot"
|
|
}
|
|
|
|
# Removed at boot by an r! entry in Finit's own legacy.conf
|
|
touch "${SYSROOT:-$(pwd)/$TEST_DIR/sysroot}/fastboot"
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$TEST_DIR/lib/setup.sh"
|
|
|
|
sep
|
|
say 'Finit runs the boot-only entries, and removes, at boot'
|
|
assert_exists /fastboot no
|
|
|
|
run "cat > $CONF" <<CONF
|
|
d $DIR
|
|
f $DIR/always
|
|
f! $DIR/boot
|
|
f+! $DIR/plus-boot - - - - text
|
|
f!+ $DIR/boot-plus - - - - text
|
|
r! $DIR/always
|
|
CONF
|
|
|
|
sep
|
|
say 'Without --boot they are skipped'
|
|
tmpfiles --create --remove
|
|
assert_exists $DIR/always yes
|
|
assert_exists $DIR/boot no
|
|
assert_exists $DIR/plus-boot no
|
|
assert_exists $DIR/boot-plus no
|
|
|
|
sep
|
|
say 'With --boot they run, remove before create'
|
|
tmpfiles --create --remove --boot
|
|
assert_exists $DIR/boot yes
|
|
assert "Modifiers in any order" "$(texec cat $DIR/plus-boot $DIR/boot-plus)" = "texttext"
|
|
assert_exists $DIR/always yes
|
|
tmpfiles --remove --boot
|
|
assert_exists $DIR/always no
|