]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-07-PID1: Test access to allocated loop instead of loop0
authorRichard Maw <richard.maw@codethink.co.uk>
Wed, 17 Apr 2024 12:03:12 +0000 (13:03 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 May 2024 09:57:09 +0000 (11:57 +0200)
loop0 and 1 can be used by systemd-repart and vanish
but we can guarantee that $LODEV was allocated and is available.

test/units/testsuite-07.exec-context.sh

index 10388d8526b1e59da0abe9179761899d075ac811..a3379ef402064ce5cad0d761a181dfc843689efa 100755 (executable)
@@ -158,13 +158,13 @@ if ! systemd-detect-virt -cq; then
         -p DevicePolicy=closed
         -p DevicePolicy=strict
         -p DeviceAllow="char-mem rm"  # Allow read & mknod for /dev/{null,zero,...}
-        -p DeviceAllow="/dev/loop0 rw"
-        -p DeviceAllow="/dev/loop0 w" # Allow write for /dev/loop0
+        -p DeviceAllow="$LODEV rw"
+        -p DeviceAllow="$LODEV w" # Allow write for the loop
         # Everything else should be disallowed per the strict policy
     )
 
     systemd-run --wait --pipe --unit "$SERVICE_NAME" "${ARGUMENTS[@]}" \
-        bash -xec 'test -r /dev/null; test ! -w /dev/null; test ! -r /dev/loop0; test -w /dev/loop0; test ! -r /dev/tty; test ! -w /dev/tty'
+        bash -xec "test -r /dev/null; test ! -w /dev/null; test ! -r $LODEV; test -w $LODEV; test ! -r /dev/tty; test ! -w /dev/tty"
 
     if ! systemctl --version | grep -qF -- "-BPF_FRAMEWORK"; then
         # SocketBind*=