tmpfiles: let %T and %V follow $TMPDIR

The %T and %V specifiers are always /tmp and /var/tmp.  In systemd
both are the first of $TMPDIR, $TEMP, and $TMP that is set to an
absolute path of a directory, and only otherwise /tmp and /var/tmp.

Do the same.  At boot none of them are set, so nothing changes there.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-21 17:14:03 +01:00
1 parent c349d564d4
commit 9ea64e5c3c
4 files changed
+29 -4

No files matched your search

+10
View File
@@ -50,3 +50,13 @@ assert "Skipped: a lone % and an unknown specifier" "$(texec sh -c "ls $DIR | gr
assert "OS ID and version" "$(texec ls $DIR/os-finit-test-1.2)" = "$DIR/os-finit-test-1.2"
assert "Architecture" "$(texec sh -c "ls $DIR | grep -c '^arch-.'")" = "1"
assert "Empty when not in os-release" "$(texec ls $DIR/variant-)" = "$DIR/variant-"
sep
say "%T and %V follow \$TMPDIR when it is a directory"
run "cat > $CONF" <<CONF
f $DIR/tmpdir - - - - %T %V
CONF
run "TMPDIR=$DIR /libexec/finit/tmpfiles --create $CONF"
assert "From the environment" "$(texec cat $DIR/tmpdir)" = "$DIR $DIR"
run "rm $DIR/tmpdir; TMPDIR=/no/such/dir /libexec/finit/tmpfiles --create $CONF"
assert "Not a directory" "$(texec cat $DIR/tmpdir)" = "/tmp /var/tmp"