tmpfiles: reject unused argument fields

Line types which do not use the argument field used to warn and ignore
a non-empty field. Treat that as invalid configuration instead, so typos
are not silently accepted.

Follow-up for: 614cc34f3a
This commit is contained in:
dongshengyuan
2026-07-28 16:40:24 +08:00
parent d47b07d05f
commit e347f63b0f
6 changed files with 24 additions and 7 deletions

View File

@@ -21,12 +21,19 @@ test ! -e /tmp/fifo
test ! -e /tmp/test
# Test invalid config
ret=0
systemd-tmpfiles --inline --remove 'garbage' || ret=$?
test "$ret" -eq 65 # EX_DATAERR
ret=0
systemd-tmpfiles --inline --create 'd /tmp/test - - - - unexpected' || ret=$?
test "$ret" -eq 65 # EX_DATAERR
echo 'garbage' >/tmp/config.conf
ret=0
systemd-tmpfiles --remove /tmp/config.conf || ret=$?
test "$ret" -eq 65 # EX_DATAERR
ret=0
systemd-tmpfiles --remove /tmp/config-missing.conf || ret=$?
test "$ret" -eq 1

View File

@@ -84,7 +84,7 @@ else
fi
# Check for an invalid "age" and "age-by" arguments.
for a in ':' ':1s' '2:1h' 'nope:42h' '" :7m"' 'm:' '::' '"+r^w-x:2/h"' 'b ar::64'; do
for a in ':' ':1s' '2:1h' 'nope:42h' '" :7m"' 'm:' '::' '"+r^w-x:2/h"' '"b ar::64"'; do
systemd-tmpfiles --clean - <<EOF 2>&1 | grep -F 'Invalid age' >/dev/null
d /tmp/ageby - - - ${a} -
EOF