FS#11818 - [PATCH] netcfg misleading "Failed to connect to wpa_supplicant" message

Attached to Project: Arch Linux
Opened by Tim Smith (redlever) - Tuesday, 21 October 2008, 06:14 GMT
Last edited by James Rayner (iphitus) - Monday, 16 February 2009, 10:56 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To James Rayner (iphitus)
Architecture All
Severity Medium
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Even when things are working properly, netcfg often reports the following:

Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory

Actually, it is the wpa_check() function in /usr/lib/network/wireless.subr. netcfg does:

1) start wpa_supplicant -wB, which returns immediately (before the daemon has opened its control socket)
2) wpa_check() does: wpa_cli status | grep wpa_state

The wpa_cli call often happens before wpa_supplicant has created the ctrl_interface socket, so wpa_cli fails to connect. This error message is confusing for users who are trying to debug connection problems (and distracting even once the netcfg setup is working).

It can be argued that upstream wpa_supplicant daemon should not return until the control socket is available. See upstream bug http://w1.fi/bugz/show_bug.cgi?id=283

netcfg2 can work around this by just suppressing this error output. Here's a patch:

--- /tmp/wireless.subr.orig 2008-10-21 00:02:13.000000000 -0600
+++ /usr/lib/network/wireless.subr 2008-10-20 23:23:56.000000000 -0600
@@ -9,7 +9,7 @@
[[ -z "$TIMEOUT" ]] && TIMEOUT=15
let timeout=0
while [[ $timeout -ne $TIMEOUT ]]; do
- eval `wpa_cli status|grep wpa_state`
+ eval `wpa_cli status 2> /dev/null | grep wpa_state`
[[ "$wpa_state" = "COMPLETED" ]] && return 0
sleep 1
let timeout++

Steps to reproduce:

Using core/netcfg 2.1.2-1 and core/wpa_supplicant 0.5.10-1

$ cat /etc/network.d/wlan-god
CONNECTION="wireless"
INTERFACE=wlan0
SCAN="yes"
SECURITY="wpa-config"
WPA_CONF="/etc/wpa_supplicant.conf"
#WPA_OPTS="-Dwext -B -iwlan0"
ESSID="god"
IP="dhcp"
DHCP_TIMEOUT=60
TIMEOUT=20

$ cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
ssid="god"
psk=[REMOVED]
}

$ sudo sh -x /usr/bin/netcfg2 wlan-god
...
+ wpa_supplicant -wB -P/var/run/wpa_supplicant_wlan0.pid -iwlan0 -c /etc/wpa_supplicant.conf -Dwext
+ sleep 1
+ [[ ! -f /var/run/wpa_supplicant_wlan0.pid ]]
+ wpa_check wlan0 20
+ INTERFACE=wlan0
+ TIMEOUT=20
+ [[ -z 20 ]]
+ let timeout=0
+ [[ 0 -ne 20 ]]
++ wpa_cli status
++ grep wpa_state
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
+ eval
+ [[ '' = \C\O\M\P\L\E\T\E\D ]]
+ sleep 1
+ let timeout++
+ [[ 1 -ne 20 ]]
++ wpa_cli status
++ grep wpa_state
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
+ eval
+ [[ '' = \C\O\M\P\L\E\T\E\D ]]
+ sleep 1
+ let timeout++
+ [[ 2 -ne 20 ]]
++ wpa_cli status
++ grep wpa_state
Failed to connect to wpa_supplicant - wpa_ctrl_open: No such file or directory
+ eval
+ [[ '' = \C\O\M\P\L\E\T\E\D ]]
+ sleep 1
+ let timeout++
+ [[ 3 -ne 20 ]]
++ wpa_cli status
++ grep wpa_state
+ eval wpa_state=COMPLETED
++ wpa_state=COMPLETED
+ [[ COMPLETED = \C\O\M\P\L\E\T\E\D ]]
+ return 0
...


I'm calling this "Medium" severity because it is quite misleading regarding why netcfg is failing. In my case, I needed to increase DHCP_TIMEOUT significantly, but it took a long time to determine this because I was trying to find out what was wrong with wpa_supplicant.
This task depends upon

Closed by  James Rayner (iphitus)
Monday, 16 February 2009, 10:56 GMT
Reason for closing:  Won't fix
Comment by James Rayner (iphitus) - Monday, 16 February 2009, 10:56 GMT
The output is useful to identify other errors, such as config errors when using custom config.

As this only occurs infrequently and netcfg is migrating to a newer wpa/dbus based setup I'm choosing to leave this as is.

Loading...