]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: ensure journal dir is writable by container in TEST-13-NSPAWN
authorLuca Boccassi <luca.boccassi@gmail.com>
Sat, 13 Sep 2025 15:14:17 +0000 (16:14 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 14 Sep 2025 12:23:17 +0000 (13:23 +0100)
The systemd-journal group is not mapped, so ensure the test directory
is owned by root:root so that the mapping works.

Follow-up for 88fce090263ba8944cf491346eae2e8022dfd88d

test/units/TEST-13-NSPAWN.nspawn.sh

index fabb1a3d3061f1ca52f268c7c611e49e63cd706a..9e83137292d0bd276780fdf3c5539a4b376c7842 100755 (executable)
@@ -1454,20 +1454,21 @@ testcase_link_journal_host() {
 
     systemd-id128 new > "$root"/etc/machine-id
 
-    mkdir -p /var/log/journal
-
-    hoge="/var/log/journal/$(cat "$root"/etc/machine-id)/hoge"
+    hoge="/var/log/journal/$(cat "$root"/etc/machine-id)/"
+    mkdir -p "$hoge"
+    # The systemd-journal group is not mapped, so ensure the directory is owned by root:root
+    chown root:root "$hoge"
 
     for i in no yes pick; do
         systemd-nspawn \
             --directory="$root" --private-users="$i" --link-journal=host \
             bash -xec 'p="/var/log/journal/$(cat /etc/machine-id)"; mountpoint "$p"; [[ "$(stat "$p" --format=%u)" == 0 ]]; touch "$p/hoge"'
 
-        [[ "$(stat "$hoge" --format=%u)" == 0 ]]
-        rm "$hoge"
+        [[ "$(stat "${hoge}/hoge" --format=%u)" == 0 ]]
+        rm "${hoge}/hoge"
     done
 
-    rm -fr "$root"
+    rm -fr "$root" "$hoge"
 }
 
 testcase_cap_net_bind_service() {