Sample Header Ad - 728x90

wpa_supplicant end process if wrong password detected

17 votes
1 answer
2588 views
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?*
Asked by Philip Kirkbride (10746 rep)
Nov 26, 2017, 09:50 PM
Last activity: Aug 4, 2025, 12:04 PM