tmpfiles.d(5) has h to set file attributes, as chattr(1) does, and H
for the path and everything below it:
h /var/log/journal - - - - +C
tmpfiles skipped them as unsupported.
Add both. The argument is the letters chattr(1) has, after a + to
add them, which is the default, a - to remove them, or a = to have
just these set. Only files and directories have such attributes,
anything else is left alone.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
tmpfiles.d(5) has t to set extended attributes on a path, and T for
the path and everything below it:
t /srv/www - - - - user.mime_type=text/html
tmpfiles skipped them as unsupported.
Add both. The argument is one or more NAME=VALUE with space between,
a value with space in it goes in quotes. They are set with
lsetxattr(), a link is never followed.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
tmpfiles.d(5) has L? for a link that is only made when what it points
to exists:
L? /etc/localtime - - - - ../usr/share/zoneinfo/UTC
The ? was not read, so this made the link whatever was there.
Finit has had this as its own l entry. Read L? as l.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A package that ships a tmpfiles.d file wants its own paths created
when it is installed, without running every other entry on the
system:
tmpfiles --create --prefix=/var/lib/app
Add the option, it can be given more than once. It and
--exclude-prefix compare whole path components now, before
--exclude-prefix=/dev also left out /devices.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
An entry with %a, or one of the specifiers that come from os-release,
was skipped as unsupported:
d /var/lib/app/%o-%w 0755 - - -
Add %o, %w, %W, %B, %M, and %A, read from /etc/os-release with
/usr/lib/os-release as fallback, and %a with the names tmpfiles.d(5)
has for the architectures. A field that os-release lacks gives an
empty string, as in tmpfiles.d(5). An entry is still skipped when
the architecture is not one of those known.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Only one number with one unit was read from the age of an entry. An
age like this one was taken as two days:
d /var/tmp 1777 root root 2d12h
What came after the first unit was not looked at. ms and us were not
known, so 500ms gave no cleaning at all.
Read any number of values with units, us, ms, s, m or min, h, d, and
w, and refuse an age that cannot be read or that overflows. Add the ~
prefix, which keeps what is right in the directory, and the prefix
that says which timestamps to go by, e.g. "aAmM:" for access and
modification time of files and directories.
Without that prefix the birth time of a file now counts too, as in
tmpfiles.d(5). It is read with statx(), where the C library has it,
and left out on a file system that has none.
A prefix that names timestamps for files only, or directories only,
leaves the default set for the other. The age is capped at what a 32
bit time_t holds, and nothing is cleaned when it reaches back past
the epoch.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
An entry with a % in the path was skipped, and files from
distributions have them:
d /run/log/journal/%m 2755 root systemd-journal - -
Expand the specifiers that do not need the OS release or the
architecture: %b, %m, %H, %l, %v, the directories %t, %T, %V, %S, %C,
%L, %h, and the user ones %u, %U, %g, %G. tmpfiles runs as root, so
the last ones are fixed. An entry with any other specifier is still
skipped.
The argument of C, f, F, L, and w entries is expanded too, as in
tmpfiles.d(5). A literal % in such an argument must from now on be
written %%.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
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 <troglobit@gmail.com>
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>
Several types read the mode and owner of an entry and did nothing
with them. An f entry was skipped when the file was there:
f /var/log/app.log 0640 app adm
This left a file with another mode or owner as it was. The owner of
p, b, and c entries was never set, and their mode was cut by the
umask. C, z, and Z entries had neither applied.
Set them for all of these, Z for everything below the path. Fifos
and device nodes are opened with O_PATH, so nothing is opened for
real. A path that is not what the entry makes, like a directory
where a p entry wants a fifo, is left alone.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
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>
What an unknown user in an entry did depended on the type. A d entry
was skipped, but this one made a file owned by root:
f /run/frr/state 0640 frr frr
The user was looked up in each type on its own, and only d checked
the result.
Look it up once for the entry, and skip the entry when the user is
not known. An unknown group leaves the group of the path as it is,
for a new path that is the group of root, as before. Both are only
reported with --debug, Finit's own files have entries for services
that may not be installed.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Finit only runs tmpfiles at boot, to create and remove. The age of an
entry has no effect until something calls tmpfiles --clean, and the
documentation said there was no aging at all.
Describe how to call it from cron, with a service as the fallback on a
system without cron, and what cleaning leaves alone. Update the
tmpfiles TODO to match.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
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>