%t and the other directory specifiers are parsed as normal paths.
They are prefixed by --root= later, so the specifier itself must stay
rootless.
Reproducer:
tmp=$(mktemp -d /tmp/tmpfiles-root.XXXXXX)
conf=$(mktemp /tmp/tmpfiles-conf.XXXXXX)
printf 'd %%t/tmpfiles-repro 0755 - - -\n' >"$conf"
systemd-tmpfiles --root="$tmp" --create --dry-run "$conf"
Before:
Would create directory $tmp/$tmp/run/tmpfiles-repro
Follow-up for
de61a04b188f81a85cdb5c64ddb4987dcd9d30d3.
if (r < 0)
return r;
- if (arg_root) {
- _cleanup_free_ char *j = NULL;
-
- j = path_join(arg_root, p);
- if (!j)
- return -ENOMEM;
-
- *ret = TAKE_PTR(j);
- } else
- *ret = TAKE_PTR(p);
+ *ret = TAKE_PTR(p);
return 0;
}
L %h - - - -
EOF
test "$(readlink "$dst")" = "$src"
+
+# Check that directory specifiers are not prefixed with --root twice.
+root='/tmp/L/3'
+rm -rf "$root"
+mkdir -p "$root"
+
+output="$(systemd-tmpfiles --create --dry-run --root="$root" - 2>&1 <<EOF
+d %t/test - - - -
+EOF
+)"
+[[ "$output" == *"Would create directory $root/run/test"* ]]
+[[ "$output" != *"$root$root"* ]]