15

I wanted to disable systemd unwanted attempts to automatically start wpa_supplicant. I thougth I could simply run a

sudo systemctl disable wpa_supplicant.service --global

and I would not be seeing a wpa_supplicant in ps -ef output anymore. Anyway this did not work. How can I make it work?

My problem at hand might be best described by the output of

$>systemctl status wpa_supplicant*
● wpa_supplicant.service - WPA supplicant
   Loaded: loaded (/usr/lib/systemd/system/wpa_supplicant.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-08-28 20:57:37 CEST; 14min ago

where as you can see the disabled service is anyway loaded and active, thanks to systemd completely helping me do the simpletest thing ;)

Update
I seem to have had some luck by brutely removing these files:

[email protected]
wpa_supplicant.service
[email protected]
[email protected]

from /usr/lib/systemd/system folder. Guess what? After restart wpa is finally not started by systemd anymore. It strikes me though there must have been a more peaceful / conciliatory way to get systemd to have the service not being started.

GChuf
  • 228
  • 2
  • 6
humanityANDpeace
  • 13,722
  • 13
  • 61
  • 107
  • Did masking the unit do nothing for you? – Kalvin Lee Aug 28 '16 at 20:26
  • @KalvinLee I am not sure if what I did (removing the files) and masking (to my undestanding that would be keeping links named as those files which point to `/dev/null` is not essentually much of the same thing.) What you suggest is something I try. I must have not been looking enough in unix.se to see that `disbale vs mask systemd` question. I will try and state back soon, to update the question – humanityANDpeace Aug 28 '16 at 21:17
  • Did disabling the template ([email protected]) help? – maxf Aug 29 '16 at 07:54
  • 1
    @maxf yes (see that in the update I did remove also the template file) and that worked. I guess the real answer here was that what Kalvin Lee suggessted namely that really disabeling (not get it to start , even as a dependence or else, is to `mask` it). `systemctl mask` is the real disable (meaning the service is not there later on). – humanityANDpeace Aug 29 '16 at 09:05

5 Answers5

7

The sudo systemctl disable wpa_supplicant + sudo systemctl stop wpa_supplicant will ONLY temporarily disable wpa_supplicant service until the network manager restarts and/or the system reboots.

So, to correctly and/or completely disable the wpa_supplicant service from running again in the future even after the network manager restarts and/or the system reboots is to mask the service, i.e.

systemctl mask wpa_supplicant.service

etc., as pointed out in this article. This will create a symbolic file

/etc/systemd/system/wpa_supplicant.service → /dev/null

I hope this helps.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
Habibie
  • 71
  • 1
  • 1
5

I ran into the same issue as yours. After some digging, I found a folder called:

/usr/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service

This is file is used to allow the service to be activated by d-bus. d-bus can activate the service even if it is disabled. I confirmed that this was happening by re-naming the file, and then rebooting. I saw that at this point wpa_supplicant had not been started! To chase the issue down further would required finding out what program is activating wpa_supplicant via d-bus. I have not done this as masking the unit file works fine for my purposes.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
BrettB
  • 51
  • 1
  • 2
  • 1
    Note that NetworkNanager requires wpa_supplicant running ([url](https://forums.fedoraforum.org/showthread.php?259183-Does-NetworkManager-use-Wpa_Supplicant)). After I removed the file above, I lost access to wifi networks. – user3804598 Jan 05 '20 at 10:47
2

I tried following BrettB's suggestion, but it had no effect on my system. (Ubuntu 18.04.)

However, the following did work:

sudo systemctl disable wpa_supplicant
Mike Nakis
  • 121
  • 3
2

All the previous answers are excessive. You can just disable NetworkManager's use of wpa_supplicant to manage wifi clients:

nmcli radio wifi off

After this, NetworkManager won't try to manage wifi devices as clients. Now you can just disable/stop the wpa_supplicant service without worrying that it will start automatically:

systemctl disable wpa_supplicant
systemctl stop wpa_supplicant

Note that NM might still be managing an active network interface for a wifi connection. To kill this, just do nmcli c to view the interfaces, and then:

nmcli c d wlan0

... for a wifi interface named wlan0.

ChalkTalk
  • 131
  • 3
1

It isn't really systemd that's being annoying here, it's NetworkManager. You can tell NetworkManager to ignore wlan0.

There are some good ideas in this thread already. I thought I'd add what I do to this list.

  • @GChuf's method - Force NetworkManager to fail by deleting systemd files. Delete files so NetworkManager is shouting into the void. I'm not sure if this method would survive a package update.
  • @Habibie's method - Force NetworkManager to fail by masking wpa_supplicant. This makes NetworkManager try a few times then give up.
  • @ChalkTalk's method - Force NetworkManager to fail by turning off the radio. Looks like it runs systemd-rfkill.service.

check the default setup

The default NetworkManager setup is to try to manage whatever it can get its hands on. NetworkManager runs wpa_supplicant to manage the WIFI interface wlan0. Here it is in the process list.

[nick@rpi4 ~]$ ps -fC wpa_supplicant
UID          PID    PPID  C STIME TTY          TIME CMD
root         593       1  0 14:36 ?        00:00:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -s
[nick@rpi4 ~]$ 

Wlan0 doesn't connect, and NetworkManager keeps trying. Messages like these appear in the journal every few minutes.

[nick@rpi4 ~]$ journalctl -f

Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info>  [1615822023.9272] device (wlan0): set-hw-addr: set MAC address to AA:9D:10:50:87:5B (scanning)
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info>  [1615822023.9359] device (wlan0): supplicant interface state: disconnected -> interface_disabled
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info>  [1615822023.9362] device (p2p-dev-wlan0): supplicant management interface state: disconnected -> interface_disabled
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info>  [1615822023.9367] device (wlan0): supplicant interface state: interface_disabled -> inactive
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info>  [1615822023.9369] device (p2p-dev-wlan0): supplicant management interface state: interface_disabled -> inactive

The status of wlan0 is disconnected.

[nick@rpi4 ~]$ nmcli device status
DEVICE         TYPE      STATE                   CONNECTION               
wlan0          wifi      disconnected            --                 

Tell NetworkManager that wlan0 is unmanaged

Edit the NetworkManager config and tell NetworkManager to ignore wlan0.

Stop the services.

systemctl stop NetworkManager
systemctl stop wpa_supplicant

Add these lines to the bottom of the config file, /etc/NetworkManager/NetworkManager.conf. If you want a description of what unmanaged-devices is, run man NetworkManager.conf.

[keyfile]
unmanaged-devices=interface-name:wlan0

Then run systemctl start NetworkManager.

Device state changes from disconnected to unmanaged. The wpa_supplicant process doesn't start again, even though it's not masked.

[nick@rpi4 ~]$ nmcli device status
DEVICE      TYPE      STATE                   CONNECTION
wlan0       wifi      unmanaged               --   
...
[nick@rpi4 ~]$ ps -fC wpa_supplicant
UID          PID    PPID  C STIME TTY          TIME CMD
[nick@rpi4 ~]$