]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: also order glob child/parent relationships 10858/head
authorLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 15:32:23 +0000 (16:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 20 Nov 2018 15:36:29 +0000 (16:36 +0100)
This is necessary so that "r" can be nested and are always executed in
the same order.

Fixes: #10191
src/tmpfiles/tmpfiles.c
test/TEST-22-TMPFILES/test-07.sh [new file with mode: 0755]

index ea09abdb1c0de75e91e0d951a294f4206d3ddea3..acde15e2d8ef0bf4f0d4b9706ad3ada021834e05 100644 (file)
@@ -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 (executable)
index 0000000..39c04b9
--- /dev/null
@@ -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 - <<EOF
+r /tmp/test-prefix
+r /tmp/test-prefix/file
+EOF
+
+! test -f /tmp/test-prefix/file
+! test -f /tmp/test-prefix
+
+mkdir /tmp/test-prefix
+touch /tmp/test-prefix/file
+
+systemd-tmpfiles --remove - <<EOF
+r /tmp/test-prefix/file
+r /tmp/test-prefix
+EOF
+
+! test -f /tmp/test-prefix/file
+! test -f /tmp/test-prefix