Question on C code - any programmatic way of settingDBUS_BUS_SESSION address?

John (J5) Palmieri johnp at
Wed Apr 23 09:40:16 PDT 2008

On Wed, 2008-04-23 at 14:48 +0300, Andrejus Chaliapinas wrote:
> > If you want to connect to a bus at a non-standard address, you shouldn't
> > be using "the" shared session-bus connection as returned by dbus_bus_get.
> > dbus_bus_get sets up and returns a shared connection - just because *you*
> > want to connect to a non-standard address for the session bus doesn't mean
> > that any other libraries or components in your process want to do the
> > same.
> >
> Yes, I understand that. That's why using 'export
> DBUS_SESSION_BUS_ADDRESS=<non-standard address>' works for all such
> specifics components started separatedly via shell scripts. Those components
> actually use dbus_bus_get_private call.
> > For a bus at a non-standard location, instead of calling dbus_bus_get(),
> > use
> > dbus_connection_open() (or possibly dbus_connection_open_private())
> > followed
> > by dbus_bus_register().
> >
> Well, my question was exactly related to that. Why do I need to deal with
> some internals (dbus_connection_open, dbus_bus_register, etc.) instead of
> having dbus_bus_get_private_by_address, which will do that all for me?

Because that is the API for connecting to non-standard buses.  My guess
is you application is no longer connecting to a "session bus" in the
dbus sense of the term, so why are you overloading it?  The public API
is two calls for connecting to non-standard buses as opposed to one call
for well known buses (plus whatever code you would write to overload
session bus).  We aren't going to add the API because that just bloats
the library.  I'm not really sure what you want to do.  Can you explain
further?  If you are looking to inject a session bus into your session's
environment (as opposed to just your program's environment) that can't
be done because environments are inherited from their parents.  Think of
the env variable as an implementation detail.  In the future we might
have a new system.  Mac OSX uses another method (or at least there are
patches for it) since env can't be propagated to the session in a
dynamic way.

John (J5) Palmieri <johnp at>

More information about the dbus mailing list