From d52747c99e27d520a5f00f5207042f6f4bf0d838 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 31 Dec 2013 15:43:17 +0200 Subject: [PATCH] wpaspy: Do not leave socket files behind if connection fails Ctrl::__init__ needs to handle socket.connect() exceptions and unlink the client socket file on failures. Signed-hostap: Jouni Malinen --- wpaspy/wpaspy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py index 9836c2df5..7c2314dc2 100644 --- a/wpaspy/wpaspy.py +++ b/wpaspy/wpaspy.py @@ -22,7 +22,12 @@ class Ctrl: self.local = "/tmp/wpa_ctrl_" + str(os.getpid()) + '-' + str(counter) counter += 1 self.s.bind(self.local) - self.s.connect(self.dest) + try: + self.s.connect(self.dest) + except Exception, e: + self.s.close() + os.unlink(self.local) + raise self.started = True def __del__(self):