]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-07-PID1: check if PrivateBPF=yes is gracefully ignored 38238/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 16 Jul 2025 00:41:50 +0000 (09:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Jul 2025 11:25:42 +0000 (20:25 +0900)
test/units/TEST-07-PID1.private-bpf.sh

index ce25fc4b16bf0badd72aab8b36903c656504063c..d9c0218055129d6c76ecb2952b73e75bb31acf16 100755 (executable)
@@ -13,12 +13,26 @@ systemd-run --wait \
         grep -q '/sys/fs/bpf .* ro,' /proc/mounts
 
 # Check that with PrivateBPF=yes, a new bpffs instance is mounted
-systemd-run --wait \
+if ! systemd-run --wait \
         -p PrivateUsers=yes \
         -p PrivateMounts=yes \
         -p DelegateNamespaces=mnt \
         -p PrivateBPF=yes \
-        grep -q '^none /sys/fs/bpf bpf rw' /proc/mounts
+        grep -q '^none /sys/fs/bpf bpf rw' /proc/mounts; then
+
+    # If it does not work, maybe the kernel is old or the system has buggy ubuntu kernel.
+    # Let's check if PrivateBPF=yes is ignored gracefully in that case.
+    systemd-run --wait \
+                -p PrivateUsers=yes \
+                -p PrivateMounts=yes \
+                -p DelegateNamespaces=mnt \
+                -p ProtectKernelTunables=yes \
+                -p PrivateBPF=yes \
+                grep -q '/sys/fs/bpf .* ro,' /proc/mounts
+
+    # Skip all remaining tests.
+    exit 0
+fi
 
 # Check that when specifying the delegate arguments, the mount options are set properly
 check_mount_opts() {