Normally when I run wpa_supplicant
I'll get some output like this:
Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
wlan3: Trying to associate with 9c:3d:cf:fb:95:96 (SSID='Bell420' freq=2462 MHz)
wlan3: Association request to the driver failed
wlan3: Associated with 9c:3d:cf:fb:95:96
wlan3: Authentication with 9c:3d:cf:fb:95:96 timed out.
ioctl[SIOCSIWAP]: Operation not permitted
wlan3: CTRL-EVENT-DISCONNECTED bssid=9c:3d:cf:fb:95:96 reason=3 locally_generated=1
wlan3: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
The problem is it just keeps trying over and over.
Is there a way I can tell wpa_supplicant
to quit as soon as it gets an obvious error like wrong key?
I'm on an older embedded device with wpa_supplicant v2.1
.
I wrote a workaround for monitoring wpa_supplicant
for incorrect keys. Using grep
on wpa_supplicant
(with stdbuf
based on Stéphane Chazelas' comment here):
# Create conf file with ssid and password
wpa_passphrase "$ssid" "$password" > /etc/wpa_supplicant/wpa_supplicant.conf
# If wifi key is wrong kill subshell
subshell=$BASHPID
(sudo stdbuf -o0 wpa_supplicant -Dwext -iwlan1 -c/etc/wpa_supplicant/wpa_supplicant.conf 2>&1 \
| grep -m 1 "pre-shared key may be incorrect" \
&& kill -s PIPE "$subshell") &
Note: the above block is inside a subshell in a script.
It seemed to work initially but over time I found sometimes it would cause the whole script to fail when the password was fine. Other times it would work as expected.
There must be a better way to do this.
Edit: Maybe I should be using wpa_cli
here instead?
wpa_supplicant.conf
?wpa_passphrase "$ssid" "$password" > /etc/wpa_supplicant/wpa_supplicant.conf
if you really want to know my wifi $ssid and $password it is Bell420 and philiprichardkirkbride. Set those and runwpa_passphrase
and you'll have my conf :-)disable_network
the offending network withwpa_cli
? (BTW, dowpa_cli help
, the man-page doesn't contain all commands).timeout
on the whole process. If I could more quickly detect a wrong password I could lower the wrong password scenario from 85 seconds to 45 seconds. So yes I know the password is wrong because I'm purposely testing that scenario, correct password works fine.CTRL-EVENT-DISCONNECTED
event show up inwpa_cli
? Can you try to add a wrapper to/sbin/wpa_action
(or modify it directly) and in this way catch the event/