System vs. session bus

Joerg Barfurth jub at
Sun Feb 15 10:54:03 PST 2009

wolfy schrieb:

> I wrote a simple notification icon for the (gnome-)systray. When a certain
> (python-)script is called, this icon changes state.
> The script can be called in one of two ways:
> * As callback from the network manager (i.e. as root)
> * As normal user prior to starting an application (i.e. as current user)

So what does this script do? Does it change or affect something owned by 
the user? In that case, how does the version running as root get access? 
Does it break, if the user's home is not accessible as root?

Or does it affect system state that is shared between all sessions? In 
this case how does it get access to affected resources when running as 
the user? How would it work on a multi-seat system (i.e. when there is 
more than one 'current user')?

In the former case it might be more appropriate to run it under the 
user's account upon a (system bus) signal from the network manager.

In the latter case it should signal on the system bus and notification 
icons in all users' sessions can listen.

> My systray notification icon exports its API (two simple "on"/"off" methods)
> to the session dbus, which works great when the script is called as current
> user.
> When the script is called by the network manager, these methods are (not
> surprisingly...) not found on the session dbus (which is now the root
> user's).
> Either I have to access the session dbus from the root account (which is
> discussed in the aforementioned thread and is as it seems not a good idea
> and/or not possible).
> Or I have to export the methods on the system bus, which does not sound like
> a good practice to me (or is it?), as the notification icon is not really a
> system service... just out of interest, I tried this approach and came
> across the issue, that the script, run as normal user, was not allowed to
> connect/export to the system bus... I have not resolved this right now, but
> I'm sure it's easily possible by tweaking some dbus privilege settings - I
> just started using the dbus for  the first time 3 hours ago, so I'm happy
> with the progress made *so* far ;-) and I will only follow this approach
> after my Q is answered:
> Which is the better or best option:
> 1) Letting the systray icon connect to the system dbus?
> 2) Trying to work around the problem that the script run as root cannot
> connect to the user's session dbus (if possible at all)?
> 3) some other option(s) I have overlooked so far?

The best option to have a reaction in a user session upon an event 
somewhere in the system (as in network manager) is to send a signal on 
the system bus. You user session can have a listener on the system bus, 
that triggers whatever changes are appropriate.

- Jörg

More information about the dbus mailing list