7

I wrote a Python program to switch WiFi connections via the Network Manager dbus interface, which (I believe) is basically equivalent to the nmcli command-line tool. The script (and nmcli) work properly when run by an unprivileged user on my desktop Ubuntu. I'm trying to figure out how the permissions to allow that were set up.

I'm asking because the same commands don't work on Raspbian, so I'd like to track down where the permissions are different. On Raspbian, when I run my script as an unprivileged user, I get this error when I try to read NetworkManager data via dbus:

dbus.exceptions.DBusException: org.freedesktop.NetworkManager.Settings.PermissionDenied: No session found for uid 1000 (unknown)

and, equivalently, when I run nmcli c as an unprivileged user on Raspbian, it doesn't show the connections as it should. Both work properly with sudo.

My attempts so far

I found some old Ubuntu posts that suggest the PolicyKit package is involved, and that I should create a file /etc/polkit-1/localauthority/50-local.d/org.freedesktop.NetworkManager.pkla with these contents:

[Enable NetworkManager]
Identity=unix-group:netdev
Action=org.freedesktop.NetworkManager.*
ResultAny=yes
ResultInactive=yes
ResultActive=yes

That didn't change anything though. (Notes: all other /etc/polkit-1/localauthority subfolders are empty, and the user is part of the netdev group. I'm not sure what else to check.)

I'm very new to dbus and NetworkManager, so I'd appreciate any help understanding how the permissions to send dbus signals are granted, and how I can troubleshoot a missing NetworkManager permission.

6
  • The polkit fill you created, did it have the pkla extension?
    – muru
    Commented Mar 7, 2017 at 13:35
  • 1
    No session found for uid 1000 sounds like something more fundamental than a permissions issue - how exactly are you executing the script, in particular is there a running desktop session with a valid DBUS_SESSION_BUS_ADDRESS for the invoking user? Commented Mar 7, 2017 at 13:37
  • 1
    logind is responsible for managing the sessions that network manager is complaining about. Perhaps check that the service is running. Try running loginctl to see if it lists any sessions.
    – bwduncan
    Commented Mar 7, 2017 at 14:32
  • Thanks guys; the file does have the pkla extension (just edited my question to add that). bwduncan and steeldriver , I think you guys might be on to something. I've been running the script via SSH or with supervisord at startup (the system is for a robot so it doesn't have a graphical desktop installed). loginctl says '0 sessions listed'. Does that prevent policykit from working? If so, is there a workaround?
    – Luke
    Commented Mar 7, 2017 at 21:35
  • Also, ps aux shows that /lib/systemd/systemd-logind is running as root. There are definitely no systemd user sessions though. I'm having trouble figuring out how to add one, as all docs I can find just say that they should exist.
    – Luke
    Commented Mar 7, 2017 at 23:18

1 Answer 1

0

"No session found for uid 1000" being solved by reinstalling dbus package.

apt install dbus

then it's important to reboot, as dbus configs gets upgraded only after.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .