Commit Graph

19 Commits (vlan_per_psk)

Author SHA1 Message Date
Jouni Malinen ed14b29f38 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>
3 years ago
Johannes Berg 27fb429e95 wpaspy: Allow building with python3
Add the necessary modified module registration code to allow building
wpaspy with python3. Also clean up the wpaspy_close() function to not
poke into the python version specific details.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
4 years ago
Jouni Malinen 30885edb7e wpaspy: Be a bit more careful on detaching the control interface
Check that the client socket is still open before trying to detach the
control interface to avoid undesired exceptions on cleanup paths on
unexpected errors due to the socket getting closed.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
4 years ago
Jouni Malinen 3a833d95b3 wpaspy: Convert to/from str to bytes as needed for python3
The control interface commands use mostly ASCII or UTF-8 strings, so
convert input/output to strings/bytes as needed for the socket
operations with python3.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years ago
Masashi Honma 00a41ed986 tests: Remove deprecated statement for python3 compatibility
This patch is made by using 2to3 command.

find . -name *.py | xargs 2to3 -f future -w -n

This was not really needed in this file for python2 compatibility.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
5 years ago
Masashi Honma 89896c0008 tests: Use python3 compatible print statement
This patch is made by using 2to3 command.

$ find . -name *.py | xargs 2to3 -f print -w -n

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
5 years ago
Masashi Honma bab493b904 tests: Use python3 compatible "except" statement
This patch is made by using 2to3 command.

$ find . -name *.py | xargs 2to3 -f except -w -n

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
5 years ago
Preston Hunt 945604a355 Update wpaspy.py to be python3 compatible
Make minor changes to wpaspy module that enables it to run in either
python2 or python3.

Signed-off-by: Preston Hunt <preston.hunt@intel.com>
7 years ago
Jonathan Afek 93568233bc wpaspy: Fix potentially referencing non existing attribute
In wpaspy.py in the Ctrl object constructor there is a try/except. In
the except part the code references the s attribute of the object. This
attribute is only created later in the try part. If an exception occurs
before the attribute creation then the except part references a non
existing attribute. Fix that by assigning None to the s attribute at the
beginning of the try part.

Signed-off-by: Jonathan Afek <jonathanx.afek@intel.com>
8 years ago
Janusz Dziedzic 13073011b9 wpaspy: Add support for TERMINATE command
This can be used to terminate the wpa_supplicant/hostapd process.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
8 years ago
Janusz Dziedzic a2c88a8025 wpaspy: Add support for UDP connection
hostname and port can now be specified when using wpaspy.Ctrl, so we can
connect to remote clients now.

This can also be tested using test.py application with
./test.py <hostname> <port>

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
8 years ago
Jouni Malinen 19318861a5 wpaspy: Handle DETACH response more robustly
There could be pending unsolicited event messages on the monitor socket
when the DETACH command is issued. As such, the response may be
something else then OK even if the actual detach operation succeeded.
Try to avoid this be dropping pending messages before issuing the detach
command. As an additional workaround, check the response against FAIL
instead of requiring OK so that the self.attached does not get left to
True incorrectly even if an additional event message were to be
received.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years ago
Jouni Malinen c2149b08da tests: Wait longer for hostapd REMOVE command to complete
Some kernel debugging options (especially
CONFIG_DEBUG_KOBJECT_RELEASE=y) can add significant blocking time to
interface removal with NL80211_CMD_DEL_INTERFACE and
SIOCGIFBR(BRCTL_DEL_BRIDGE) block for 1-8 seconds. This could result in
the VLAN test cases failing due to a wpaspy timeout on the REMOVE
command even though the issue was only in the kernel debugging code
making the operations significantly slower. Work around this by using a
longer timeout for that control interface command to allow this type of
debug kernel to be used.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
10 years ago
Jouni Malinen 606110e647 wpaspy: Add optional timeout argument for pending()
This can be used to wait for up to the specified limit on new event
messages.

Signed-hostap: Jouni Malinen <j@w1.fi>
10 years ago
Jouni Malinen d52747c99e 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 <j@w1.fi>
10 years ago
Jouni Malinen b44db5f6d6 wpaspy: Fix tracking of attached status
The attached variable was initialized and checked, but never updated.
Fix that by updating it on successful ATTACH/DETACH command.

Signed-hostap: Jouni Malinen <j@w1.fi>
10 years ago
Jouni Malinen 09491b7392 wpaspy: Add native Python implementation of ctrl_iface access
This can be used as a replacement for the wpaspy.c module that uses
wpa_ctrl.c to access wpa_supplicant/hostapd control interface. Only
the UNIX domain socket version of the control interface is currently
supported.

Signed-hostap: Jouni Malinen <j@w1.fi>
11 years ago
Jouni Malinen 15cb4772d6 wpaspy: Fix exception handling in the test script
Signed-hostap: Jouni Malinen <j@w1.fi>
11 years ago
Jouni Malinen 20da5c8986 wpaspy: Add Python bindings for wpa_ctrl
This allows Python to be used to control wpa_supplicant/hostapd through
the control interface.

Signed-hostap: Jouni Malinen <j@w1.fi>
11 years ago