tmpfiles: skip an entry that takes its argument from a credential

A ^ after the type says the argument is the name of a credential to
read the real argument from.  Files from systemd have them:

    f^ /etc/hosts - - - - network.hosts

The ^ was not read, so on a system without /etc/hosts this made one
holding the text "network.hosts".

Finit has no credentials.  Skip the entry, which is what systemd does
when the credential is not set.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 19:10:04 +01:00
1 parent ddb4f18fa9
commit 81ce7a2833
4 files changed
+18 -3

No files matched your search

+5
View File
@@ -303,6 +303,11 @@ All relevant changes are documented in this file.
- Fix `tmpfiles --clean` for an `e` entry with a glob in the path, like - Fix `tmpfiles --clean` for an `e` entry with a glob in the path, like
`e /var/cache/* - - - 10d`, nothing was cleaned. The age of a `C` `e /var/cache/* - - - 10d`, nothing was cleaned. The age of a `C`
entry is now used as well entry is now used as well
- Fix tmpfiles entries with a `^` after the type, as in `f^`, where the
argument names a credential. The name was written to the file, with
files from systemd that gave an `/etc/hosts` holding `network.hosts`
when there was none. Finit has no credentials, such an entry is now
skipped, as systemd does when the credential is not set
- Fix mode of a new file from a tmpfiles `f` entry without a mode, it is - Fix mode of a new file from a tmpfiles `f` entry without a mode, it is
now 0644 as in tmpfiles.d(5), before it followed the umask now 0644 as in tmpfiles.d(5), before it followed the umask
- Fix tmpfiles `w` entries with a glob that matches several paths, all - Fix tmpfiles `w` entries with a glob that matches several paths, all
+7 -3
View File
@@ -13,9 +13,10 @@ files or common packages already rely on, last what few will miss.
* `C+`, which is read as `C` * `C+`, which is read as `C`
* `z` and `Z` only set the SELinux label when `restorecon` is installed * `z` and `Z` only set the SELinux label when `restorecon` is installed
* Modifiers `=` (remove what is of another type), `~` (base64 * Modifiers `=` (remove what is of another type) and `~` (base64
argument), and `^` (credential as argument). `-` (do not fail) has argument). `-` (do not fail) has nothing to do, tmpfiles never exits
nothing to do, tmpfiles never exits with an error for an entry with an error for an entry, and an entry with `^` (credential as
argument) is skipped, Finit has no credentials
* Quoted paths, a path with a space in it cannot be written * Quoted paths, a path with a space in it cannot be written
@@ -38,4 +39,7 @@ Missing options: `--root`, `--replace`, `--purge`, `--graceful`, and
by that age, the age is not read by that age, the age is not read
* The `%T` and `%V` specifiers are always `/tmp` and `/var/tmp`, they * The `%T` and `%V` specifiers are always `/tmp` and `/var/tmp`, they
do not look at `$TMPDIR` do not look at `$TMPDIR`
* A `w` entry truncates the file, systemd writes over the start of
what is there. It only matters for a regular file, not in `/proc`
or `/sys`
* `mksubsys()` in `src/util.c` is unused * `mksubsys()` in `src/util.c` is unused
+2
View File
@@ -1381,6 +1381,8 @@ static void tmpfiles(char *line)
boot = 1; boot = 1;
else if (*mod == '?' && type[0] == 'L') else if (*mod == '?' && type[0] == 'L')
type[0] = 'l'; /* What Finit has had as l */ type[0] = 'l'; /* What Finit has had as l */
else if (*mod == '^')
return; /* Argument is a credential, there are none */
} }
if (boot && !boot_flag) if (boot && !boot_flag)
return; return;
+4
View File
@@ -21,6 +21,7 @@ d $DIR - - - - -
L $DIR/aligned - - - - /dev/null L $DIR/aligned - - - - /dev/null
f $DIR/dash - - - - - f $DIR/dash - - - - -
f $DIR/text - - - - two words f $DIR/text - - - - two words
f^ $DIR/cred - - - - some.credential
CONF CONF
run "/libexec/finit/tmpfiles --create $CONF" run "/libexec/finit/tmpfiles --create $CONF"
@@ -31,6 +32,9 @@ assert "File content" "$(texec cat $DIR/text)" = "two words"
say 'A lone - is no argument' say 'A lone - is no argument'
assert "Empty file" "$(texec stat -c %s $DIR/dash)" = "0" assert "Empty file" "$(texec stat -c %s $DIR/dash)" = "0"
say 'An entry that takes its argument from a credential is skipped'
assert "No file" "$(texec sh -c "ls $DIR | grep -c cred")" = "0"
sep sep
say 'L? only makes the link when what it points to is there' say 'L? only makes the link when what it points to is there'
run "cat > $CONF" <<CONF run "cat > $CONF" <<CONF