mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
An entry with a % in the path was skipped, and files from
distributions have them:
d /run/log/journal/%m 2755 root systemd-journal - -
Expand the specifiers that do not need the OS release or the
architecture: %b, %m, %H, %l, %v, the directories %t, %T, %V, %S, %C,
%L, %h, and the user ones %u, %U, %g, %G. tmpfiles runs as root, so
the last ones are fixed. An entry with any other specifier is still
skipped.
The argument of C, f, F, L, and w entries is expanded too, as in
tmpfiles.d(5). A literal % in such an argument must from now on be
written %%.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
41 lines
1.4 KiB
Bash
Executable File
41 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Verify the % specifiers of tmpfiles.d(5), in the path and the argument
|
|
set -eu
|
|
|
|
TEST_DIR=$(dirname "$0")
|
|
|
|
DIR=/tmp/specifier
|
|
CONF=/tmp/specifier.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
|
|
f $DIR/host-%H
|
|
f $DIR/kernel-%v
|
|
f $DIR/machine-%m
|
|
f $DIR/boot-%b
|
|
f $DIR/100%%
|
|
f $DIR/end%
|
|
f $DIR/unknown - - - - %!
|
|
f $DIR/arg - - - - %T %V %t %S %C %L %h %u %U %g %G %l
|
|
CONF
|
|
run "/libexec/finit/tmpfiles --create $CONF"
|
|
|
|
host=$(texec hostname)
|
|
assert "Hostname" "$(texec ls $DIR/host-"$host")" = "$DIR/host-$host"
|
|
assert "Kernel release" "$(texec ls $DIR/kernel-"$(texec uname -r)")" = "$DIR/kernel-$(texec uname -r)"
|
|
assert "Machine ID" "$(texec ls $DIR/machine-"$(texec cat /etc/machine-id)")" = "$DIR/machine-$(texec cat /etc/machine-id)"
|
|
boot=$(texec cat /proc/sys/kernel/random/boot_id | tr -d -)
|
|
assert "Boot ID" "$(texec ls $DIR/boot-"$boot")" = "$DIR/boot-$boot"
|
|
assert "Percent" "$(texec ls $DIR/100%)" = "$DIR/100%"
|
|
assert "In the argument" "$(texec cat $DIR/arg)" = "/tmp /var/tmp /run /var/lib /var/cache /var/log /root root 0 root 0 ${host%%.*}"
|
|
assert "Skipped: a lone % and an unknown specifier" "$(texec sh -c "ls $DIR | grep -c -e end -e unknown")" = "0"
|