Valid HTML 4.01 Transitional
Prev: Building a SuSE RPM Package Next: UEFI Booting for OpenSuSE
(Index)
Jim Carter's Bugfixes

Making wpa_cli and wpa_supplicant Work With dbus

James F. Carter
2017-04-09
Symptom:

wpa_supplicant is running. You try to use wpa_cli or wpa_gui to inspect or control it, but wpa_cli maunders, Failed to connect to non-global ctrl_ifname: (null), error: No such file or directory.

What's happening:

Maybe it failed to connect to the non-global control interface because that socket does not exist :-) There is very little documentation on the web for how to get past this issue.

Modern wpa_supplicant versions (mine is 2.2) have two control interfaces: a dbus API, and a directory, normally /var/run/wpa_supplicant/ or /run/wpa_supplicant/ depending on the distro, containing a socket named for each Wi-fi interface that wpa_supplicant is managing. The control interfaces are not active by default. You need the -u command line option to get dbus, and -O /var/run/wpa_supplicant (or whichever directory) for the sockets. wpa_supplicant will create the directory if not existing.

NetworkManager needs the dbus interface. wpa_cli and wpa_gui don't know about dbus and require the socket. If there are several wireless NICs being managed, give e.g. -i wlan0 to wpa_cli to pick one, but this is not necessary if only one NIC is operating.

How to fix:

This is for systemd, and specifically OpenSuSE Leap 42.1. You will need to fix the command line options in different files if your distro uses Upstart, or LSB init scripts.

As root, copy the distro's wpa_supplicant script into /etc/systemd/system, edit the ExecStart command line adding -u and/or -O /var/run/wpa_supplicant (or wherever wpa_cli wants to find the directory), refresh systemd, reenable wpa_supplicant, and restart wpa_supplicant.

cp -p -i /usr/lib/systemd/system/wpa_supplicant.service /etc/systemd/system/
vi /etc/systemd/system/wpa_supplicant.service #Use your favorite editor
systemctl daemon-reload #So systemd knows about the fixed service unit
systemctl reenable wpa_supplicant #So systemd will use it at boot
systemctl restart wpa_supplicant #So wpa_supplicant gets the new option right away

In some distros, wpa_supplicant may be started by dbus itself. The dbus service file is (usually) /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ; if not there, do locate WPASupplicant.service to find it. In OpenSuSE it has a line SystemdService=wpa_supplicant.service which tells dbus to use systemd to start wpa_supplicant. If your distro's dbus service file lacks systemd integration, you will need to edit the Exec line in the file to add the -u and/or -O option. dbus-daemon will read the changes automatically.


Prev: Building a SuSE RPM Package Next: UEFI Booting for OpenSuSE
(Index)