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
This commit is contained in:
Lennart Poettering 2018-11-20 16:32:23 +01:00
parent 09f467ac24
commit bd0ce2447d
2 changed files with 33 additions and 0 deletions

View 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)

View File

@ -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