]> tinc-vpn.org Git - tinc/commitdiff
Skip raw socket test if we don't have the required privileges
authorGuus Sliepen <guus@sliepen.org>
Fri, 3 Apr 2026 15:10:51 +0000 (17:10 +0200)
committerGuus Sliepen <guus@sliepen.org>
Fri, 3 Apr 2026 15:10:51 +0000 (17:10 +0200)
This can happen in an unprivileged container where it looks like we are
root, but we don't have NET_RAW privileges.

test/integration/device_raw_socket.py

index d536390e8cef10fef59c20c2b26e24e98c6bdd35..b2bbf1140b67c5d3bed22194ff38ef1067c2e6f9 100755 (executable)
@@ -4,6 +4,7 @@
 
 import sys
 import subprocess as subp
+import socket
 
 from testlib import check, util
 from testlib.log import log
@@ -15,6 +16,13 @@ from testlib.external import veth_add, move_dev, ping
 util.require_root()
 util.require_command("ip", "link")
 
+try:
+    s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.IPPROTO_IP)
+    print("Success!")
+except PermissionError:
+    log.info("This test requires raw socket privileges")
+    sys.exit(77)
+
 FAKE_DEV = "cqhqdr7knaLzYeMSdy"
 
 IP_NETNS = "10.198.96.1"