Home | History | Annotate | Download | only in dbus
      1 Launchd[1,2] replaces init, inetd and cron on Mac OS X since 10.4 "Tiger".
      2 dbus uses this service to provide a common session bus address for each user
      3 and so deprecates the X11 enabled dbus-launcher.
      4 
      5 [1] http://developer.apple.com/MacOsX/launchd.html
      6 [2] http://launchd.macosforge.org/
      7 
      8 
      9 Setup
     10 ===
     11 
     12 Configure with --enable-launchd and --without-x (X11 should not harm but it's
     13 simply not necessary any more)
     14 After installation, to prevent a reboot, load the dbus session starter into
     15 launchd by executing:
     16 $ launchctl load /Library/LaunchAgents/org.freedesktop.dbus-session.plist
     17 
     18 You can change the launch agent dir via configure, but it's not recommended.
     19 Make sure to execute the above line as the actual user for which you want to
     20 use a session bus since launchd manages its agents on a per user basis.
     21 
     22 
     23 How it works
     24 ===
     25 
     26 Launchd allocates a socket and provides the unix path to it via the variable
     27 DBUS_LAUNCHD_SESSION_BUS_SOCKET in launchd's environment. Every process
     28 spawned by launchd (or dbus-daemon, if stared by launchd) can access it through
     29 its own environment. Other processes can query launchd for it by executing:
     30 $ launchctl getenv DBUS_LAUNCHD_SESSION_BUS_SOCKET
     31 However, this is normally done by the dbus client lib for you.
     32 
     33 If launchd start dbus-daemon with a config file containing a "launchd:env=FOO"
     34 address, as the default session config does with env=DBUS_LAUNCHD_SESSION_BUS_SOCKET,
     35 the daemon will get the file descriptor from launchd and start listening on it.
     36 The environment variable is used to get the actual socket path which is passed
     37 to every service spawned by dbus-daemon as a result from autolaunch messages.
     38 Please note that it's not possible to start dbus-daemon manually when using a
     39 "launchd:" address. Only child processes of launchd can access the above
     40 mentioned file descriptor!
     41 
     42 To create custom buses just set up an other launch agent. As a quick start copy
     43 /Library/LaunchAgents/org.freedesktop.dbus-session.plist, change the label
     44 to i.e. "org.freedesktop.dbus-foo" and change the SecureSocketWithKey value,
     45 i.e. to "DBUS_LAUNCHD_FOO_BUS_SOCKET". This environment variable has to be set
     46 in the config file for your new bus in the <listen> element (see session.config).
     47 Then edit your /Library/LaunchAgents/org.freedesktop.dbus-foo.plist to start
     48 dbus-daemon with "--config-file=/opt/local/etc/dbus-1/foo.conf" instead of
     49 "--session". Now load the new plist onto launchd as described in the setup
     50 section of this document.
     51 Executing "launchctl export" should now give you two sockets, one in
     52 DBUS_LAUNCHD_SESSION_BUS_SOCKET and the new DBUS_LAUNCHD_FOO_BUS_SOCKET.
     53 To connect to this new bus use "launchd:env=DBUS_LAUNCHD_FOO_BUS_SOCKET".
     54 
     55 Since Mac OS X 10.5 "Leopard" you can also configure launchd to start
     56 dbus-daemon on demand as soon as some process connects to the socket. Since
     57 it's broken on 10.4 this feature is disabled per default. Look at
     58 /Library/LaunchAgents/org.freedesktop.dbus-session.plist to change it.
     59 
     60 On the client side, the envvar DBUS_SESSION_BUS_ADDRESS can be normally used
     61 but if it's not set, launchd is queried for the session bus socket.
     62