From fd78fd122ac9fe94944effc00320284ae9041120 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Nov 2018 15:56:22 +0100 Subject: [PATCH 1/5] man: minor fixes As suggested here: https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207 --- man/tmpfiles.d.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From 48d96904301154d81b32d2c58ec6c96cb3689210 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Nov 2018 15:56:55 +0100 Subject: [PATCH 2/5] =?UTF-8?q?tmpfiles:=20behind=20=E2=86=92=20below=20in?= =?UTF-8?q?=20log=20msgs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As suggested here: https://github.com/systemd/systemd/pull/10538#pullrequestreview-176710207 --- src/tmpfiles/tmpfiles.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 9de9498d486..249365f3da9 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 */ From 44ac4f88549c8411d1898fe38363a4a2668a8dda Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Nov 2018 16:15:09 +0100 Subject: [PATCH 3/5] tmpfiles: label phases explicitly --- src/tmpfiles/tmpfiles.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 249365f3da9..40a435487db 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -3171,10 +3171,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 +3255,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"); From 09f467ac2482daa150b35e0a7c1fbddd726e4b10 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Nov 2018 16:32:19 +0100 Subject: [PATCH 4/5] tmpfiles: fix typo --- src/tmpfiles/tmpfiles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 40a435487db..ea09abdb1c0 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -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. */ From bd0ce2447d4e8be510e605699f866605274d6c71 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 20 Nov 2018 16:32:23 +0100 Subject: [PATCH 5/5] tmpfiles: also order glob child/parent relationships This is necessary so that "r" can be nested and are always executed in the same order. Fixes: #10191 --- src/tmpfiles/tmpfiles.c | 2 ++ test/TEST-22-TMPFILES/test-07.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 test/TEST-22-TMPFILES/test-07.sh diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index ea09abdb1c0..acde15e2d8e 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -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) 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 - <