getProperties method not found for NetworkManager

913 views Asked by At

I am going through dbus-python tutorial.

https://dbus.freedesktop.org/doc/dbus-python/tutorial.html#interfaces-and-methods

The example provided does not work for me. I replaced the eth0 with 1 but still it throws an error.

import dbus
bus = dbus.SystemBus()
eth0 = bus.get_object('org.freedesktop.NetworkManager',
                      '/org/freedesktop/NetworkManager/Devices/eth0')
eth0_dev_iface = dbus.Interface(eth0,
    dbus_interface='org.freedesktop.NetworkManager.Devices')
props = eth0_dev_iface.getProperties()

Error:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send
message, 2 matched rules; type="method_call", sender=":1.4371" (uid=78105 pid=8231 
comm="python3 " label="unconfined") interface="org.freedesktop.NetworkManager.Devices" 
member="getProperties" error name="(unset)" requested_reply="0" destination=":1.11" 
(uid=0 pid=1122 comm="/usr/sbin/NetworkManager --no-daemon " label="unconfined")

Also there is this below statement

For instance, each NetworkManager object representing a network interface implements the interface org.freedesktop.NetworkManager.Devices, which has methods like getProperties.

I checked with d-feet, somehow the interface of network manager does not have getProperties method

1

There are 1 answers

0
thaller On BEST ANSWER

'/org/freedesktop/NetworkManager/Devices/eth0' is not a D-Bus path that you'll see on NetworkManager's D-Bus API.

You said, you were checking with d-feet. There you'll see that on NetworkManager's D-Bus API, objects commonly have a number at the end. So D-Bus paths to device "objects" are named like /org/freedesktop/NetworkManager/Devices/1.

Try also busctl tree org.freedesktop.NetworkManager.

I checked with d-feet, somehow the interface of network manager does not have getProperties method

NetworkManager's D-Bus API doesn't literally have a getProperties method. It implements the standard D-Bus API with org.freedesktop.DBus.Properties interface as specified (https://dbus.freedesktop.org/doc/dbus-specification.html). Maybe the python bindings expose that as a getProperties() method...

Try:

  $ busctl call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/1 org.freedesktop.DBus.Properties Get ss org.freedesktop.NetworkManager.Device Path`

and

  $ busctl -j call org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/1 org.freedesktop.DBus.Properties GetAll s org.freedesktop.NetworkManager.Device