How to debug dbus access issues?
tomw
tomw at ubilix.com
Wed Aug 24 01:43:18 PDT 2011
Hi,
to nail down my issue I wrote two simple test cases, which are identical
except the bus names are different. The .conf files
in /etc/dbus-1/system.d are identical as well.
What quite puzzles me is that the two identical objects behave
differently, "bar" works as expected "baz" gets an AccessDenied error:
>>> import dbus
>>> bus = dbus.SystemBus()
>>> bar = bus.get_object("org.foo.Bar", "/org/foo/Bar")
>>> baz = bus.get_object("org.foo.Baz", "/org/foo/Baz")
>>> baz.GetStatus()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 68, in
__call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 140, in
__call__
**keywords)
File "/usr/lib/python2.6/site-packages/dbus/connection.py", line 630,
in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied:
Rejected send message, 5 matched rules; type="method_call",
sender=":1.15" (uid=500 pid=1386 comm="python) interface="(unset)"
member="GetStatus" error name="(unset)" requested_reply=0
destination=":1.13" (uid=500 pid=1380 comm="python))
>>> bar.GetStatus()
dbus.String(u'Bar : I am doing fine')
>>>
using dbus-send however I got what I was expecting:
$ dbus-send --system --print-reply --dest=org.foo.Bar /org/foo/Bar
org.foo.Bar.GetStatusmethod return sender=:1.16 -> dest=:1.17
reply_serial=2
string "Bar : I am doing fine"
$ dbus-send --system --print-reply --dest=org.foo.Baz /org/foo/Baz
org.foo.Baz.GetStatus
method return sender=:1.13 -> dest=:1.18 reply_serial=2
string "Baz : I am doing fine"
Anyone has an idea about how to explain this?
------------------------------------------------------------------
Here's the two test cases and their .conf files, which are pretty
straight forward.
#test bar.py
import dbus
import dbus.service
import gobject
import dbus.mainloop.glib
OBJ = "org.foo.Bar"
PATH= '/' + OBJ.replace('.','/')
class BarObject(dbus.service.Object):
def __init__(self, bus, bus_path):
dbus.service.Object.__init__(self, bus, bus_path)
@dbus.service.method(OBJ, in_signature='', out_signature='s')
def GetStatus(self):
return("Bar : I am doing fine")
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
name = dbus.service.BusName(OBJ, bus)
b = BarObject(bus, PATH)
mainloop = gobject.MainLoop()
mainloop.run()
#test baz.py
import dbus
import dbus.service
import gobject
import dbus.mainloop.glib
OBJ = "org.foo.Baz"
PATH= '/' + OBJ.replace('.','/')
class BazObject(dbus.service.Object):
def __init__(self, bus, bus_path):
dbus.service.Object.__init__(self, bus, bus_path)
@dbus.service.method(OBJ, in_signature='', out_signature='s')
def GetStatus(self):
return("Baz : I am doing fine")
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
name = dbus.service.BusName(OBJ, bus)
b = BazObject(bus, PATH)
mainloop = gobject.MainLoop()
mainloop.run()
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="meego">
<allow own="org.foo.Bar"/>
</policy>
<policy user="root">
<allow own="org.foo.Bar"/>
</policy>
<policy context="default">
<allow send_destination="org.foo.Bar"/>
<allow receive_sender="org.foo.Bar"/>
</policy>
</busconfig>
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- -->
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="meego">
<allow own="org.foo.Baz"/>
</policy>
<policy user="root">
<allow own="org.foo.Baz"/>
</policy>
<policy context="default">
<allow send_destination="org.foo.Baz"/>
<allow receive_sender="org.foo.Baz"/>
</policy>
</busconfig>
More information about the dbus
mailing list