mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: do not truncate the file of a w entry
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>
This commit is contained in:
4 files changed
+26
-7
No files matched your search
@@ -65,6 +65,16 @@ run "/libexec/finit/tmpfiles --create $CONF"
|
||||
assert "First match" "$(texec cat $DIR/w1 | tr '\n' ' ')" = "one two"
|
||||
assert "Second match" "$(texec cat $DIR/w2 | tr '\n' ' ')" = "one two"
|
||||
|
||||
sep
|
||||
say 'w writes over the start of what is there, w+ adds to the end'
|
||||
run "printf abcdef > $DIR/w1"
|
||||
run "cat > $CONF" <<'CONF'
|
||||
w /tmp/arg/w1 - - - - XY
|
||||
w+ /tmp/arg/w1 - - - - Z
|
||||
CONF
|
||||
run "/libexec/finit/tmpfiles --create $CONF"
|
||||
assert "Written in place" "$(texec cat $DIR/w1)" = "XYcdefZ"
|
||||
|
||||
sep
|
||||
say 'Escapes, and a # that is not at the start of the line'
|
||||
run "cat > $CONF" <<'CONF'
|
||||
|
||||
Reference in new issue
Block a user