From 3bc7c83731bc310d4e39a99754140e2133d9b0e3 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 20 Nov 2026 12:00:50 +0100 Subject: [PATCH] tmpfiles: skip the space before the argument of an entry An entry written in aligned columns got the space after the age field as part of its argument: L /tmp/null - - - - /dev/null This made a link to " /dev/null". Only the first separator after the age was dropped. A lone "-" for no argument was also taken as is, so an f entry with it made a file holding a dash. Skip all the space before the argument, and read "-" as no argument. Signed-off-by: Joachim Wiberg --- doc/ChangeLog.md | 3 +++ src/tmpfiles.c | 5 +++++ test/Makefile.am | 2 ++ test/tmpfiles-arg.sh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100755 test/tmpfiles-arg.sh diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index a7c08f08..d07581e3 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -243,6 +243,9 @@ All relevant changes are documented in this file. - Fix owner of existing directories and files in tmpfiles, an entry with no user or group, or `-`, reset them to `root`. As in tmpfiles.d(5), the owner and the group are now each left alone unless the entry gives them +- Fix the argument of a tmpfiles entry written in aligned columns, the space + after the age field ended up in the argument, e.g. in the target of an `L` + link. A lone `-` is now read as no argument - Fix a lost reload for a service paused mid-reload by a condition in flux. A second reload arriving meanwhile re-parsed the unchanged .conf and cleared the pending mark, so the service resumed without ever being diff --git a/src/tmpfiles.c b/src/tmpfiles.c index 34fbb162..4b5b3a49 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -430,6 +430,11 @@ static void tmpfiles(char *line) age = strtok(NULL, "\t "); arg = strtok(NULL, "\n"); + if (arg) { + arg += strspn(arg, "\t "); + if (!arg[0] || !strcmp(arg, "-")) + arg = NULL; + } strc = stat(path, &st); diff --git a/test/Makefile.am b/test/Makefile.am index 67280643..26886021 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -81,6 +81,7 @@ EXTRA_DIST += start-stop-sysv.sh EXTRA_DIST += start-stop-serv.sh EXTRA_DIST += signal-service.sh EXTRA_DIST += testserv.sh +EXTRA_DIST += tmpfiles-arg.sh EXTRA_DIST += tmpfiles-perm.sh EXTRA_DIST += unexpected-restart.sh EXTRA_DIST += dbus-auth.sh @@ -159,6 +160,7 @@ TESTS += start-stop-serv.sh TESTS += signal-service.sh if TESTSERV TESTS += testserv.sh +TESTS += tmpfiles-arg.sh TESTS += tmpfiles-perm.sh endif TESTS += unexpected-restart.sh diff --git a/test/tmpfiles-arg.sh b/test/tmpfiles-arg.sh new file mode 100755 index 00000000..03297d65 --- /dev/null +++ b/test/tmpfiles-arg.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Verify how tmpfiles reads the argument, the last field of an entry +set -eu + +TEST_DIR=$(dirname "$0") + +DIR=/tmp/arg +CONF=/tmp/arg.conf + +test_teardown() +{ + say "Running test teardown." + run "rm -rf $DIR $CONF" +} + +# shellcheck source=/dev/null +. "$TEST_DIR/lib/setup.sh" + +run "cat > $CONF" <