]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpaspy: Do not mark not-existing UNIX domain socket as UDP
authorJouni Malinen <jouni@codeaurora.org>
Mon, 1 Mar 2021 10:51:20 +0000 (12:51 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 1 Mar 2021 10:51:20 +0000 (12:51 +0200)
os.stat(path) failure is an ambigious indication of the control
interface "path" type (UDP hostname vs. UNIX domain socket path). The
path may be a valid UNIX domain socket path, but that socket could have
been removed just before reaching here. At least the hwsim test case
concurrent_p2pcli managed to hit the "connect exception" print below
from UDP handling even when using a UNIX domain socket.

Work around incorrect determination of control interface socket type by
assuming anything starting with '/' is a UNIX domain socket and not a
hostname.

Fixes: a2c88a8025b2 ("wpaspy: Add support for UDP connection")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpaspy/wpaspy.py

index c50cd531e10906ca559e727b97cc6996bd600369..5b8140b7c99f562784724f85dec5f61ede16f874 100644 (file)
@@ -21,14 +21,14 @@ class Ctrl:
         self.path = path
         self.port = port
 
-        try:
-            mode = os.stat(path).st_mode
-            if stat.S_ISSOCK(mode):
-                self.udp = False
-            else:
+        self.udp = False
+        if not path.startswith('/'):
+            try:
+                mode = os.stat(path).st_mode
+                if not stat.S_ISSOCK(mode):
+                    self.udp = True
+            except:
                 self.udp = True
-        except:
-            self.udp = True
 
         if not self.udp:
             self.s = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)