When wpa_cli is used in fedora, the following error occurs:
$ wpa_cliwpa_cli v2.0Copyright (c) 2004-2012, Jouni Malinen <j@w1.fi> and contributorsThis software may be distributed under the terms of the BSD license.See README for more details.Interactive modeCould not connect to wpa_supplicant: (null) - re-trying
There are two possible causes:
1: not run with root permission
2: No control interface for/var/run/wpa_supplicant
Solution:
In/usr/lib/systemd/system/wpa_supplicant.service, add:-O/var/run/wpa_supplicant
In this way, when wpa_supplicant is started, the/var/run/wpa_supplicant control interface will be ready.
[Unit]Description=WPA Supplicant daemonBefore=network.targetAfter=syslog.target[Service]Type=dbusBusName=fi.w1.wpa_supplicant1EnvironmentFile=-/etc/sysconfig/wpa_supplicantExecStart=/usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplicant.log -c /etc/wpa_supplicant/wpa_supplicant.conf -O /var/run/wpa_supplicant $INTERFACES $DRIVERS $OTHER_ARGS[Install]WantedBy=multi-user.target
Test:
Sudo killall wpa_supplicant
PS aux | grep wpa_supplicant
Root 3140 0.0 0.1 50748 2836? SS/usr/sbin/wpa_supplicant-u-F/var/log/wpa_supplicant.log-C/etc/wpa_supplicant/wpa_supplicant.conf
-O/var/run/wpa_supplicant-U-F/var/log/wpa_supplicant.log-P/var/run/wpa_supplicant.pid
Sudo LS-Al/var/run/wpa_supplicant/
Total 0
Drwxr-x ---. 2 root Root 60 Aug 21.
Drwxr-XR-X. 39 Root 1220 Aug 21 ..
Srwxrwx ---. 1 Root 0 Aug 21 00:17 wlp3s0