Accessing Session Bus through the superuser

Ozan Çağlayan ozan at pardus.org.tr
Sun Mar 16 14:05:39 PDT 2008


Hi,

I'm trying to access the Session Bus for sending notifications to 
desktop through the superuser. I wrote a python script which acts like a 
regular user which has an X Display and an address for accessing its 
session bus. It works perfectly when run as root:

..
os.setuid(uid)
os.environ['DISPLAY'] = DISPLAY
os.environ['DBUS_SESSION_BUS_ADDRESS'] = DBUS_SESSION_BUS_ADDRESS

bus = dbus.SessionBus()
# Call org.freedesktop.Notifications.Notify()
..

The problem arises when I export some object on the system bus, just 
before the code above. The script setuids, sets the DISPLAY and 
DBUS_SESSION_BUS_ADDRESS correctly but when it tries to create the 
SessionBus() object it fails:

Traceback (most recent call last):
   File 
"/home/ozan/pardus/playground/ozan/printer-applet/src/notify-printer.py", 
line 179, in ?
     sbus = dbus.SessionBus()
   File "/usr/lib/python2.4/site-packages/dbus/_dbus.py", line 217, in 
__new__
     mainloop=mainloop)
   File "/usr/lib/python2.4/site-packages/dbus/_dbus.py", line 106, in 
__new__
     bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
   File "/usr/lib/python2.4/site-packages/dbus/bus.py", line 125, in __new__
     bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: 
org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to 
autolaunch D-Bus session: 6360: Autolaunch enabled (using X11).
6360: --exit-with-session automatically enabled
No protocol specified
Autolaunch error: X11 initialization failed.

It's trying to autolaunch a session bus using dbus-launch but it fails.

What I can't understand is why "exporting an object over the system bus" 
is triggering this error?

DBus version : 1.1.4
dbus-python: 0.82.4

Thanks.

-- 
Ozan Caglayan
http://cekirdek.pardus.org.tr/~ozan
<ozan_at_pardus.org.tr>


More information about the dbus mailing list