Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I access a machine through multiple login sessions. The sessions' lifetimes may or may not overlap. In my case, these login sessions are currently always over SSH, but I would prefer to handle local sessions too.

I sometimes need D-Bus in these sessions, and I want to share the same D-Bus session across these login sessions, in order to use GVFS.

What is the recommended way to do this? I don't want to break any use of D-Bus that I may not be aware of. I've considered using

export $(dbus-launch --autolaunch $(cat /var/lib/dbus/machine-id))

but (as of Ubuntu 12.04) this doesn't seem right:

  • this requires an X session, but my SSH sessions may or may not be forwarding an X display, and even the ones that are don't have the same $DISPLAY;
  • if no X display is available, dbus-launch complains that “Autolaunch error: X11 initialization failed.” and doesn't start a daemon;
  • the dbus-launch man page states that “The --autolaunch option is considered an internal implementation detail (…). There's no real reason to use it outside of the libdbus implementation anyhow.”

Does dbus-launch or another tool in the D-Bus suite support automatically detecting a running dbus-daemon and connecting to it? The necessary information is in ~/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-${DISPLAY#*:} if D-Bus is started with an X connection, but doesn't seem to be stored anywhere if no X connection is available.

Should I cobble my own D-Bus session file? If I do, should I use a file in the ~/.dbus/session-bus directory? Is the path /var/lib/dbus/machine-id reliable and portable?

share|improve this question
1  
This answer might be part of a solution for you: serverfault.com/questions/405518/… – sdive Oct 5 '12 at 9:18
I was fiddling with DBus a lot 2 years ago and all that is left in my memory from reading a lot, including the sources was: DBus could be cool, but is so much tailored to be run once as a system instance and exactly once again for each local user session that it's just stupid instead of cool. My guess is you have to do everything yourself. I did, but I always have X sessions so it was a little easier for me. Good luck. – user1129682 Jan 6 at 22:05
I've seen some nice info on dbus configuration in the BLFS book (Beyond Linux From Scratch). – Fiisch May 7 at 8:03

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.