From: dongshengyuan <545258830@qq.com> Date: Wed, 15 Jul 2026 05:22:04 +0000 (+0800) Subject: tmpfiles: keep directory specifiers rootless X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58496809c0fcfb2364b11b36a76e0d79d4b9dec8;p=thirdparty%2Fsystemd.git tmpfiles: keep directory specifiers rootless %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. --- diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 82f6b8da2f2..0e3244fcebe 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -322,16 +322,7 @@ static int specifier_directory( 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; } diff --git a/test/units/TEST-22-TMPFILES.15.sh b/test/units/TEST-22-TMPFILES.15.sh index 14c26b82958..68c6c301bd6 100755 --- a/test/units/TEST-22-TMPFILES.15.sh +++ b/test/units/TEST-22-TMPFILES.15.sh @@ -42,3 +42,15 @@ systemd-tmpfiles --create --root="$root" - <&1 <