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: a2c88a8025 ("wpaspy: Add support for UDP connection")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2021-03-01 12:51:20 +02:00 committed by Jouni Malinen
parent 8d80aa3fca
commit ed14b29f38

View file

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