diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml index 71dcfe870f9..7641b790af1 100644 --- a/man/tmpfiles.d.xml +++ b/man/tmpfiles.d.xml @@ -78,9 +78,9 @@ name will be applied. All other conflicting entries will be logged as errors. When two lines are prefix path and suffix path of each other, then the prefix line is always created first, the suffix later (and if removal applies to the line, the order is reversed: the suffix is removed first, the prefix later). Lines that take globs are - applied after those accepting no globs. If multiple operations shall be applied on the same file, (such as ACL, - xattr, file attribute adjustments), these are always done in the same fixed order. Otherwise, the files/directories - are processed in the order they are listed. + applied after those accepting no globs. If multiple operations shall be applied on the same file (such as ACL, + xattr, file attribute adjustments), these are always done in the same fixed order. Except for those cases, the + files/directories are processed in the order they are listed. If the administrator wants to disable a configuration file supplied by the vendor, the recommended way is to place a symlink diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 9de9498d486..acde15e2d8e 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -2268,10 +2268,10 @@ static int process_item(Item *i, OperationMask operation) { r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS, NULL); if (r == -EREMOTE) { - log_debug_errno(r, "Item '%s' is behind autofs, skipping.", i->path); + log_debug_errno(r, "Item '%s' is below autofs, skipping.", i->path); return 0; } else if (r < 0) - log_debug_errno(r, "Failed to determine whether '%s' is behind autofs, ignoring: %m", i->path); + log_debug_errno(r, "Failed to determine whether '%s' is below autofs, ignoring: %m", i->path); r = FLAGS_SET(operation, OPERATION_CREATE) ? create_item(i) : 0; /* Failure can only be tolerated for create */ @@ -3139,7 +3139,7 @@ static int link_parent(ItemArray *a) { assert(a); - /* Finds the closestq "parent" item array for the specified item array. Then registers the specified item array + /* Finds the closest "parent" item array for the specified item array. Then registers the specified item array * as child of it, and fills the parent in, linking them both ways. This allows us to later create parents * before their children, and clean up/remove children before their parents. */ @@ -3152,6 +3152,8 @@ static int link_parent(ItemArray *a) { ItemArray *j; j = ordered_hashmap_get(items, prefix); + if (!j) + j = ordered_hashmap_get(globs, prefix); if (j) { r = set_ensure_allocated(&j->children, NULL); if (r < 0) @@ -3171,10 +3173,15 @@ static int link_parent(ItemArray *a) { int main(int argc, char *argv[]) { _cleanup_strv_free_ char **config_dirs = NULL; - int r, k, r_process = 0, phase; + int r, k, r_process = 0; bool invalid_config = false; Iterator iterator; ItemArray *a; + enum { + PHASE_REMOVE_AND_CLEAN, + PHASE_CREATE, + _PHASE_MAX + } phase; r = parse_argv(argc, argv); if (r <= 0) @@ -3250,12 +3257,12 @@ int main(int argc, char *argv[]) { /* If multiple operations are requested, let's first run the remove/clean operations, and only then the create * operations. i.e. that we first clean out the platform we then build on. */ - for (phase = 0; phase < 2; phase++) { + for (phase = 0; phase < _PHASE_MAX; phase++) { OperationMask op; - if (phase == 0) + if (phase == PHASE_REMOVE_AND_CLEAN) op = arg_operation & (OPERATION_REMOVE|OPERATION_CLEAN); - else if (phase == 1) + else if (phase == PHASE_CREATE) op = arg_operation & OPERATION_CREATE; else assert_not_reached("unexpected phase"); diff --git a/test/TEST-22-TMPFILES/test-07.sh b/test/TEST-22-TMPFILES/test-07.sh new file mode 100755 index 00000000000..39c04b925cf --- /dev/null +++ b/test/TEST-22-TMPFILES/test-07.sh @@ -0,0 +1,31 @@ +#! /bin/bash +# +# Verifies the issues described by https://github.com/systemd/systemd/issues/10191 +# + +set -e +set -x + +rm -rf /tmp/test-prefix + +mkdir /tmp/test-prefix +touch /tmp/test-prefix/file + +systemd-tmpfiles --remove - <