mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: skip the space before the argument of an entry
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>
This commit is contained in:
4 files changed
+42
No files matched your search
@@ -243,6 +243,9 @@ All relevant changes are documented in this file.
|
|||||||
- Fix owner of existing directories and files in tmpfiles, an entry with no
|
- Fix owner of existing directories and files in tmpfiles, an entry with no
|
||||||
user or group, or `-`, reset them to `root`. As in tmpfiles.d(5), the
|
user or group, or `-`, reset them to `root`. As in tmpfiles.d(5), the
|
||||||
owner and the group are now each left alone unless the entry gives them
|
owner and the group are now each left alone unless the entry gives them
|
||||||
|
- Fix the argument of a tmpfiles entry written in aligned columns, the space
|
||||||
|
after the age field ended up in the argument, e.g. in the target of an `L`
|
||||||
|
link. A lone `-` is now read as no argument
|
||||||
- Fix a lost reload for a service paused mid-reload by a condition in
|
- Fix a lost reload for a service paused mid-reload by a condition in
|
||||||
flux. A second reload arriving meanwhile re-parsed the unchanged .conf
|
flux. A second reload arriving meanwhile re-parsed the unchanged .conf
|
||||||
and cleared the pending mark, so the service resumed without ever being
|
and cleared the pending mark, so the service resumed without ever being
|
||||||
|
|||||||
@@ -430,6 +430,11 @@ static void tmpfiles(char *line)
|
|||||||
|
|
||||||
age = strtok(NULL, "\t ");
|
age = strtok(NULL, "\t ");
|
||||||
arg = strtok(NULL, "\n");
|
arg = strtok(NULL, "\n");
|
||||||
|
if (arg) {
|
||||||
|
arg += strspn(arg, "\t ");
|
||||||
|
if (!arg[0] || !strcmp(arg, "-"))
|
||||||
|
arg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
strc = stat(path, &st);
|
strc = stat(path, &st);
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ EXTRA_DIST += start-stop-sysv.sh
|
|||||||
EXTRA_DIST += start-stop-serv.sh
|
EXTRA_DIST += start-stop-serv.sh
|
||||||
EXTRA_DIST += signal-service.sh
|
EXTRA_DIST += signal-service.sh
|
||||||
EXTRA_DIST += testserv.sh
|
EXTRA_DIST += testserv.sh
|
||||||
|
EXTRA_DIST += tmpfiles-arg.sh
|
||||||
EXTRA_DIST += tmpfiles-perm.sh
|
EXTRA_DIST += tmpfiles-perm.sh
|
||||||
EXTRA_DIST += unexpected-restart.sh
|
EXTRA_DIST += unexpected-restart.sh
|
||||||
EXTRA_DIST += dbus-auth.sh
|
EXTRA_DIST += dbus-auth.sh
|
||||||
@@ -159,6 +160,7 @@ TESTS += start-stop-serv.sh
|
|||||||
TESTS += signal-service.sh
|
TESTS += signal-service.sh
|
||||||
if TESTSERV
|
if TESTSERV
|
||||||
TESTS += testserv.sh
|
TESTS += testserv.sh
|
||||||
|
TESTS += tmpfiles-arg.sh
|
||||||
TESTS += tmpfiles-perm.sh
|
TESTS += tmpfiles-perm.sh
|
||||||
endif
|
endif
|
||||||
TESTS += unexpected-restart.sh
|
TESTS += unexpected-restart.sh
|
||||||
|
|||||||
Executable
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Verify how tmpfiles reads the argument, the last field of an entry
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
TEST_DIR=$(dirname "$0")
|
||||||
|
|
||||||
|
DIR=/tmp/arg
|
||||||
|
CONF=/tmp/arg.conf
|
||||||
|
|
||||||
|
test_teardown()
|
||||||
|
{
|
||||||
|
say "Running test teardown."
|
||||||
|
run "rm -rf $DIR $CONF"
|
||||||
|
}
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$TEST_DIR/lib/setup.sh"
|
||||||
|
|
||||||
|
run "cat > $CONF" <<CONF
|
||||||
|
d $DIR - - - - -
|
||||||
|
L $DIR/aligned - - - - /dev/null
|
||||||
|
f $DIR/dash - - - - -
|
||||||
|
f $DIR/text - - - - two words
|
||||||
|
CONF
|
||||||
|
run "/libexec/finit/tmpfiles --create $CONF"
|
||||||
|
|
||||||
|
say 'Space between the age and the argument is not part of the argument'
|
||||||
|
assert "Link target" "$(texec readlink $DIR/aligned)" = "/dev/null"
|
||||||
|
assert "File content" "$(texec cat $DIR/text)" = "two words"
|
||||||
|
|
||||||
|
say 'A lone - is no argument'
|
||||||
|
assert "Empty file" "$(texec stat -c %s $DIR/dash)" = "0"
|
||||||
Reference in new issue
Block a user