mark2b / wpa-connect

wpa-connect
MIT License
61 stars 19 forks source link

WPA_Supplicant DBUS Interface Permissions #6

Open buildscientist opened 3 years ago

buildscientist commented 3 years ago

@mark2b Opening this up as an issue more for documentation purposes in case anyone else runs into this. I ran into this issue while developing a Go service using your library on Ubuntu. Likely not an issue on Raspberry PI OS since it doesn't use Polkit.

When using DBUS to manage wpa_supplicant some Linux distributions utilize Polkit (formerly known as PolicyKit) to manage permissions for processes that can interface directly with the bus.

This blog provides a good treatise on the subject matter. Developers running on Debian based distro's like Ubuntu will need to modify the /etc/dbus-1/system.d/wpa_supplicant.conf to allow your user (non-root) access to interface with dbus.

Add another <policy_user> block in addition to the existing one.

<busconfig>
        <policy user="yourUserName">
                <allow own="fi.w1.wpa_supplicant1"/>

                <allow send_destination="fi.w1.wpa_supplicant1"/>
                <allow send_interface="fi.w1.wpa_supplicant1"/>
                <allow receive_sender="fi.w1.wpa_supplicant1" receive_type="signal"/>
        </policy>
</busconfig>

Note the policy user you set should be identical to the owner of the process running the Go binary using the wpa-connect library.