From ed14b29f38e2505fa27fb86fbd26b92834795fc1 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 1 Mar 2021 12:51:20 +0200 Subject: [PATCH] wpaspy: Do not mark not-existing UNIX domain socket as UDP 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 --- wpaspy/wpaspy.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py index c50cd531e..5b8140b7c 100644 --- a/wpaspy/wpaspy.py +++ b/wpaspy/wpaspy.py @@ -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)