tmpfiles: add the : and ~ prefixes for mode, user, and group

A mode with a prefix was not read as a number, so the entry was taken
to have no mode, and a user with one was looked up with the colon in
the name, which skipped the entry:

    d /var/lib/app :0750 :app :app

With : the mode, user, or group is only set on a path the entry
creates, an existing one keeps what it has.  With ~ the mode loses
read, write, or execute when no one has that on the existing path,
and setuid, setgid, and sticky when it is not a directory.

Mode and owner now go through perm_set() in tmpfiles, which knows the
entry created the path or not.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:02:37 +01:00
1 parent a726aff30b
commit ec67ecc805
4 files changed
+132 -32

No files matched your search

+7 -17
View File
@@ -21,17 +21,7 @@ user to call it from cron.
glob in the path is not cleaned
2. Prefixes that are silently dropped
-------------------------------------
* Mode `~0755`, mask with the mode the path has, and `:0755`, only
when creating: neither is parsed, the entry is read as having no
mode
* User and group `:name`, only when creating: looked up as the name
`:name`, which fails. For `d` the directory is then not created
3. Mode and owner not applied
2. Mode and owner not applied
-----------------------------
* `f` on a file that exists: the entry is skipped, tmpfiles.d(5)
@@ -41,7 +31,7 @@ user to call it from cron.
* `z`, `Z`: mode and owner, and they do nothing without `restorecon`
4. Device nodes with major or minor 0
3. Device nodes with major or minor 0
-------------------------------------
`parse_mm()` rejects a 0 in either number, so an entry like this one
@@ -50,7 +40,7 @@ is skipped:
c /dev/tty 0666 root tty - 5:0
5. Subvolumes
4. Subvolumes
-------------
`v`, `q`, and `Q` are skipped as unsupported. systemd makes a plain
@@ -58,7 +48,7 @@ directory when the file system is not btrfs, doing the same gets
distribution files with these entries to work.
6. Specifiers
5. Specifiers
-------------
A path with `%` in it is skipped, also the escaped `%%`. The ones that
@@ -68,7 +58,7 @@ and `%V`. This is the largest gap for using such files unchanged, and
the most work.
7. Remaining types and modifiers
6. Remaining types and modifiers
--------------------------------
* `L?`, and `C+`, which is read as `C`
@@ -78,7 +68,7 @@ the most work.
* Quoted paths, a path with a space in it cannot be written
8. Command line
7. Command line
---------------
Missing options: `--prefix`, `--root`, `--replace`, `--dry-run`,
@@ -87,7 +77,7 @@ is the useful one, for packages that run `tmpfiles --create` on only
their own paths.
9. Smaller things
8. Smaller things
------------------
* Files are processed one directory at a time. tmpfiles.d(5) sorts