A w entry empties the file before it writes the argument. With a file
that holds "abcdef":
w /tmp/file - - - - XY
leaves "XY". With systemd-tmpfiles the file holds "XYcdef", it writes
over the start of what is there. For a file in /proc or /sys there is
no difference.
Open the file without O_TRUNC.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
An entry with a # in the argument loses it and the rest of the line:
f /tmp/file - - - - a#b c
gives a file holding "a". The lines are read with fparseln(), which
by default takes a # anywhere in a line as the start of a comment. In
tmpfiles.d(5) only a line that starts with # is a comment.
Read the lines without a comment character and skip the lines that
start with one.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
An f or w entry with \x39 in the argument writes the byte 3 followed
by a 9, where it should write a 9:
f /tmp/file - - - - \x39
write_hex() only takes the digits 0 to 7, as for an octal escape.
Take all hex digits.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A ^ after the type says the argument is the name of a credential to
read the real argument from. Files from systemd have them:
f^ /etc/hosts - - - - network.hosts
The ^ was not read, so on a system without /etc/hosts this made one
holding the text "network.hosts".
Finit has no credentials. Skip the entry, which is what systemd does
when the credential is not set.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
A w entry with a glob wrote its whole argument to the first path
only. The rest got it up to the first backslash:
w /sys/class/net/eth*/queues/rx-0/rps_cpus - - - - f\n
write_arg() put a NUL in the argument at each escape as it went, so
the second call saw a shorter string.
Leave the argument as it is.
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 written in aligned columns got the space after the age field
as part of its argument:
L /tmp/null - - - - /dev/null
This made a link to " /dev/null". Only the first separator after
the age was dropped. A lone "-" for no argument was also taken as is,
so an f entry with it made a file holding a dash.
Skip all the space before the argument, and read "-" as no argument.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>