tmpfiles: run boot-only entries only at boot

A ! after the type marks an entry that is only safe to run at boot.
Finit's own files have them, like this one in x11.conf:

    D! /tmp/.X11-unix 1777 root root

tmpfiles ignored the ! and ran these entries on every call, so this
emptied the directory under a running X server:

    tmpfiles --remove

Only the character right after the type was looked at, and only for
a +.

Read all the modifiers after the type, in any order, and skip an
entry with ! unless the new --boot option is given.  Finit gives it
at boot, together with --remove.  Before this the r, R, and D entries
were never run at boot, so "r! /forcefsck" in legacy.conf left the
file in place.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:02:35 +01:00
1 parent 4a11294f98
commit 3c9500fc08
7 files changed
+108 -34

No files matched your search

+13 -26
View File
@@ -8,25 +8,12 @@ files or common packages already rely on, last what few will miss.
[tmpfiles.d(5)]: https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
1. Boot-only entries
--------------------
The `!` modifier marks an entry that is only safe at boot. Finit's own
files use it, `D!` and `r!` in `x11.conf`, `r!` in `legacy.conf`, and
`C!` in `etc.conf`, but the modifier is ignored and there is no `--boot`
option. The entries run on every call, so `tmpfiles --remove` on a
running system empties `/tmp/.X11-unix` and removes the X lock files.
* Parse the modifiers after the type letter, in any order
* Add `--boot`, skip `!` entries without it
* Call `tmpfiles --create --remove --boot` from `plugins/bootmisc.c`
2. Nothing runs the clean pass
1. Nothing runs the clean pass
------------------------------
Finit calls `tmpfiles --create` at boot and nothing else. The age
field has no effect until the user adds a task for `tmpfiles --clean`.
Finit calls `tmpfiles --create --remove --boot` at boot and nothing
else. The age field has no effect until the user adds a task for
`tmpfiles --clean`.
* Ship a task for it, systemd runs its timer 15 min after boot and
then daily
@@ -39,7 +26,7 @@ field has no effect until the user adds a task for `tmpfiles --clean`.
* The age is only used for `d`, `D`, and `e`
3. Prefixes that are silently dropped
2. Prefixes that are silently dropped
-------------------------------------
* Mode `~0755`, mask with the mode the path has, and `:0755`, only
@@ -52,7 +39,7 @@ field has no effect until the user adds a task for `tmpfiles --clean`.
all of them
4. Mode and owner not applied
3. Mode and owner not applied
-----------------------------
* `f` on a file that exists: the entry is skipped, tmpfiles.d(5)
@@ -62,7 +49,7 @@ field has no effect until the user adds a task for `tmpfiles --clean`.
* `z`, `Z`: mode and owner, and they do nothing without `restorecon`
5. Device nodes with major or minor 0
4. Device nodes with major or minor 0
-------------------------------------
`parse_mm()` rejects a 0 in either number, so an entry like this one
@@ -71,7 +58,7 @@ is skipped:
c /dev/tty 0666 root tty - 5:0
6. Subvolumes
5. Subvolumes
-------------
`v`, `q`, and `Q` are skipped as unsupported. systemd makes a plain
@@ -79,7 +66,7 @@ directory when the file system is not btrfs, doing the same gets
distribution files with these entries to work.
7. Specifiers
6. Specifiers
-------------
A path with `%` in it is skipped, also the escaped `%%`. The ones that
@@ -89,7 +76,7 @@ and `%V`. This is the largest gap for using such files unchanged, and
the most work.
8. Remaining types and modifiers
7. Remaining types and modifiers
--------------------------------
* `L?`, and `C+`, which is read as `C`
@@ -99,7 +86,7 @@ the most work.
* Quoted paths, a path with a space in it cannot be written
9. Command line
8. Command line
---------------
Missing options: `--prefix`, `--root`, `--replace`, `--dry-run`,
@@ -108,14 +95,14 @@ is the useful one, for packages that run `tmpfiles --create` on only
their own paths.
10. Smaller things
9. Smaller things
------------------
* Files are processed one directory at a time. tmpfiles.d(5) sorts
all of them by name, whatever directory they are in, so `00-x.conf`
in `/etc` should run before `50-y.conf` in `/usr/lib`
* `doc/README.md`, `doc/index.md`, and `doc/plugins.md` say there is
no aging. There is, see 2 above
no aging. There is, see 1 above
* `a` and `A` handle an ACL of at most 32 entries, a path with more is
left as it is, with a warning
* `mksubsys()` in `src/util.c` is unused