From 83f4dceb1b30647efadb6f7d48deb43278b93dd6 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 20 Nov 2026 17:27:33 +0100 Subject: [PATCH] tmpfiles: make a directory for v, q, and Q entries Files from distributions use v, q, and Q for directories that should be btrfs subvolumes when that is possible: v /var/lib/machines 0700 - - - tmpfiles skipped them as unsupported, so the directory was missing. On a file system without subvolumes tmpfiles.d(5) has them make a plain directory. Do that everywhere, read them as d. Signed-off-by: Joachim Wiberg --- doc/ChangeLog.md | 3 +++ doc/tmpfiles-todo.md | 16 ++++------------ src/tmpfiles.c | 4 ++++ test/tmpfiles-perm.sh | 12 ++++++++++++ 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 3d920b1e..bc238ba2 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -15,6 +15,9 @@ All relevant changes are documented in this file. skipped unless the new `--boot` option is given. Finit gives it at boot, and now also `--remove`, so `r`, `R`, and `D` entries take effect at boot and no longer need a separate call +- tmpfiles: the `v`, `q`, and `Q` entries now make a plain directory, like + `d`. Finit has no support for btrfs subvolumes, and before the entries + were skipped as unsupported - tmpfiles: add the `:` prefix for mode, user, and group, to set them only on a path the entry creates, and the `~` prefix for the mode, to drop read, write, or execute where the existing path has it for no one diff --git a/doc/tmpfiles-todo.md b/doc/tmpfiles-todo.md index 13dbaff2..861b7d47 100644 --- a/doc/tmpfiles-todo.md +++ b/doc/tmpfiles-todo.md @@ -21,15 +21,7 @@ user to call it from cron. glob in the path is not cleaned -2. Subvolumes -------------- - -`v`, `q`, and `Q` are skipped as unsupported. systemd makes a plain -directory when the file system is not btrfs, doing the same gets -distribution files with these entries to work. - - -3. Specifiers +2. Specifiers ------------- A path with `%` in it is skipped, also the escaped `%%`. The ones that @@ -39,7 +31,7 @@ and `%V`. This is the largest gap for using such files unchanged, and the most work. -4. Remaining types and modifiers +3. Remaining types and modifiers -------------------------------- * `L?`, and `C+`, which is read as `C` @@ -50,7 +42,7 @@ the most work. * Quoted paths, a path with a space in it cannot be written -5. Command line +4. Command line --------------- Missing options: `--prefix`, `--root`, `--replace`, `--dry-run`, @@ -59,7 +51,7 @@ is the useful one, for packages that run `tmpfiles --create` on only their own paths. -6. Smaller things +5. Smaller things ------------------ * Files are processed one directory at a time. tmpfiles.d(5) sorts diff --git a/src/tmpfiles.c b/src/tmpfiles.c index 20d8f3fc..f40f5ecf 100644 --- a/src/tmpfiles.c +++ b/src/tmpfiles.c @@ -884,6 +884,10 @@ static void tmpfiles(char *line) if (boot && !boot_flag) return; + /* No btrfs subvolumes, a plain directory as tmpfiles.d(5) has for other file systems */ + if (strchr("vqQ", type[0])) + type[0] = 'd'; + path = strtok(NULL, "\t "); if (!path) return; diff --git a/test/tmpfiles-perm.sh b/test/tmpfiles-perm.sh index 11a911c4..6cd6ce9f 100755 --- a/test/tmpfiles-perm.sh +++ b/test/tmpfiles-perm.sh @@ -103,3 +103,15 @@ run "touch $DIR/keep; chmod 2755 $DIR/keep; /libexec/finit/tmpfiles --create $CO assert "Mode given" "$(texec stat -c '%a %U:%G' $DIR/suid)" = "4755 bin:sys" assert "Mode not given" "$(texec stat -c '%a %U:%G' $DIR/keep)" = "2755 sys:bin" assert "Masked to 0" "$(texec stat -c '%a' $DIR/none)" = "0" + +sep +say 'v, q, and Q entries make a plain directory, like d' +run "cat > $CONF" <