tmpfiles: allow major or minor 0 in b and c entries

An entry for a device with a 0 in its number was skipped:

    c /dev/tty 0666 root tty - 5:0

parse_mm() took 0 to mean atoi() could not read the number.

Use atonum(), which tells the two apart.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:03:31 +01:00
1 parent adf7080fca
commit 777ecd77c8
3 files changed
+11 -19

No files matched your search

+2
View File
@@ -272,6 +272,8 @@ All relevant changes are documented in this file.
- Fix mode and owner of tmpfiles entries that ignored them: an `f` entry for - Fix mode and owner of tmpfiles entries that ignored them: an `f` entry for
a file that exists, the owner of `p`, `b`, and `c` entries, and both for a file that exists, the owner of `p`, `b`, and `c` entries, and both for
`C`, `z`, and `Z` entries `C`, `z`, and `Z` entries
- Fix tmpfiles `b` and `c` entries for a device with major or minor 0,
like `5:0` for `/dev/tty`, they were skipped as invalid
- Fix age `0` in a tmpfiles entry, it was read as no age. As in - Fix age `0` in a tmpfiles entry, it was read as no age. As in
tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an tmpfiles.d(5), `tmpfiles --clean` now empties the directory of such an
entry entry
+5 -14
View File
@@ -21,16 +21,7 @@ user to call it from cron.
glob in the path is not cleaned glob in the path is not cleaned
2. Device nodes with major or minor 0 2. Subvolumes
-------------------------------------
`parse_mm()` rejects a 0 in either number, so an entry like this one
is skipped:
c /dev/tty 0666 root tty - 5:0
3. Subvolumes
------------- -------------
`v`, `q`, and `Q` are skipped as unsupported. systemd makes a plain `v`, `q`, and `Q` are skipped as unsupported. systemd makes a plain
@@ -38,7 +29,7 @@ directory when the file system is not btrfs, doing the same gets
distribution files with these entries to work. distribution files with these entries to work.
4. Specifiers 3. Specifiers
------------- -------------
A path with `%` in it is skipped, also the escaped `%%`. The ones that A path with `%` in it is skipped, also the escaped `%%`. The ones that
@@ -48,7 +39,7 @@ and `%V`. This is the largest gap for using such files unchanged, and
the most work. the most work.
5. Remaining types and modifiers 4. Remaining types and modifiers
-------------------------------- --------------------------------
* `L?`, and `C+`, which is read as `C` * `L?`, and `C+`, which is read as `C`
@@ -59,7 +50,7 @@ the most work.
* Quoted paths, a path with a space in it cannot be written * Quoted paths, a path with a space in it cannot be written
6. Command line 5. Command line
--------------- ---------------
Missing options: `--prefix`, `--root`, `--replace`, `--dry-run`, Missing options: `--prefix`, `--root`, `--replace`, `--dry-run`,
@@ -68,7 +59,7 @@ is the useful one, for packages that run `tmpfiles --create` on only
their own paths. their own paths.
7. Smaller things 6. Smaller things
------------------ ------------------
* Files are processed one directory at a time. tmpfiles.d(5) sorts * Files are processed one directory at a time. tmpfiles.d(5) sorts
+4 -5
View File
@@ -133,11 +133,10 @@ static int parse_mm(char *arg, int *major, int *minor)
goto inval; goto inval;
*ptr++ = 0; *ptr++ = 0;
*major = atoi(arg); *major = atonum(arg);
*minor = atoi(ptr); *minor = atonum(ptr);
if (*major < 0 || *minor < 0)
if (!*major || !*minor) goto inval;
return -1;
return 0; return 0;
} }