mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
tmpfiles: skip an entry that is not supported, do not exit
tmpfiles exited at the first entry with a type it does not know, or
with a % specifier in the path:
h /tmp/dir - - - - +i
f /tmp/dir/after
tmpfiles --create t.conf
This never created /tmp/dir/after. At boot it meant that one such
line, in any tmpfiles.d file, stopped every entry after it, in that
file and in all the files sorted after it. The message says skipping,
but errx() exits.
Warn and go on with the next entry. With two passes, for --create
with --remove, only the second one warns.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
4 files changed
+52
-3
No files matched your search
@@ -252,6 +252,9 @@ All relevant changes are documented in this file.
|
||||
- Fix `tmpfiles --create --remove`, each entry was removed and created in
|
||||
turn, so an `r` entry removed what an entry above it had just created.
|
||||
All of the removing is now done first
|
||||
- Fix tmpfiles giving up at the first entry it does not support, an unknown
|
||||
type or a `%` specifier in the path. No entry after it was run, in that
|
||||
file or in the files after it. Such an entry is now skipped with a warning
|
||||
- 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
|
||||
and cleared the pending mark, so the service resumed without ever being
|
||||
|
||||
+11
-3
@@ -56,6 +56,9 @@ int create_flag = 0;
|
||||
int clean_flag = 0;
|
||||
int remove_flag = 0;
|
||||
|
||||
/* Set for the first of two passes, the second one does the complaining */
|
||||
static int quiet;
|
||||
|
||||
#define MAX_EXCLUDES 32
|
||||
static const char *exclude_prefixes[MAX_EXCLUDES];
|
||||
static int num_excludes;
|
||||
@@ -727,7 +730,8 @@ static void tmpfiles(char *line)
|
||||
if (!path)
|
||||
return;
|
||||
if (strchr(path, '%')) {
|
||||
errx(1, "Path name specifiers unsupported, skipping.");
|
||||
if (!quiet)
|
||||
warnx("Path name specifiers unsupported, skipping %s", path);
|
||||
return;
|
||||
}
|
||||
if (excluded(path))
|
||||
@@ -796,7 +800,8 @@ static void tmpfiles(char *line)
|
||||
case 'z':
|
||||
break;
|
||||
default:
|
||||
errx(1, "Unsupported tmpfiles command '%s'", type);
|
||||
if (!quiet)
|
||||
warnx("Unsupported tmpfiles command '%s', skipping %s", type, path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1037,7 +1042,8 @@ static void tmpfiles(char *line)
|
||||
globfree(&gl);
|
||||
break;
|
||||
default:
|
||||
errx(1, "Unsupported tmpfiles command '%s'", type);
|
||||
if (!quiet)
|
||||
warnx("Unsupported tmpfiles command '%s', skipping %s", type, path);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1214,8 +1220,10 @@ int main(int argc, char *argv[])
|
||||
/* Remove and clean first, or an r entry takes what an f entry above it made */
|
||||
if (create_flag && (clean_flag || remove_flag)) {
|
||||
create_flag = 0;
|
||||
quiet = 1;
|
||||
process(argc - optind, &argv[optind]);
|
||||
create_flag = 1;
|
||||
quiet = 0;
|
||||
clean_flag = remove_flag = 0;
|
||||
}
|
||||
process(argc - optind, &argv[optind]);
|
||||
|
||||
@@ -85,6 +85,7 @@ EXTRA_DIST += tmpfiles-acl.sh
|
||||
EXTRA_DIST += tmpfiles-arg.sh
|
||||
EXTRA_DIST += tmpfiles-perm.sh
|
||||
EXTRA_DIST += tmpfiles-order.sh
|
||||
EXTRA_DIST += tmpfiles-unsupported.sh
|
||||
EXTRA_DIST += unexpected-restart.sh
|
||||
EXTRA_DIST += dbus-auth.sh
|
||||
EXTRA_DIST += dbus-authz.sh
|
||||
@@ -166,6 +167,7 @@ TESTS += tmpfiles-acl.sh
|
||||
TESTS += tmpfiles-arg.sh
|
||||
TESTS += tmpfiles-perm.sh
|
||||
TESTS += tmpfiles-order.sh
|
||||
TESTS += tmpfiles-unsupported.sh
|
||||
endif
|
||||
TESTS += unexpected-restart.sh
|
||||
if DBUS
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# Verify that tmpfiles skips an entry it does not support, and goes on
|
||||
# with the rest
|
||||
set -eu
|
||||
|
||||
TEST_DIR=$(dirname "$0")
|
||||
|
||||
DIR=/tmp/unsupported
|
||||
CONF=/tmp/unsupported.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
|
||||
h $DIR - - - - +i
|
||||
f $DIR/%m
|
||||
f $DIR/after
|
||||
CONF
|
||||
|
||||
say 'Create only'
|
||||
msg=$(texec sh -c "/libexec/finit/tmpfiles --create $CONF 2>&1")
|
||||
assert "The entry after is created" "$(texec ls $DIR)" = "after"
|
||||
assert "Each is reported once" "$(echo "$msg" | grep -c skipping)" -eq 2
|
||||
|
||||
say 'Remove and create, two passes'
|
||||
run "rm $DIR/after"
|
||||
msg=$(texec sh -c "/libexec/finit/tmpfiles --create --remove $CONF 2>&1")
|
||||
assert "The entry after is created" "$(texec ls $DIR)" = "after"
|
||||
assert "Each is reported once" "$(echo "$msg" | grep -c skipping)" -eq 2
|
||||
Reference in new issue
Block a user