about using privileged (KAuth) helpers: system dbus daemon on OS X?
René J.V. Bertin
rjvbertin at gmail.com
Mon Sep 19 08:01:01 UTC 2016
On Sunday September 18 2016 19:11:56 Thiago Macieira wrote:
>> Is it roughly correct to say that on Linux an application will try to
>> connect on the system bus if it doesn't find a session bus address?
>Applications connect to the bus they were designed to connect to. If they
>can't, they exit with error.
>$ DBUS_SESSION_BUS_ADDRESS= DISPLAY= qdbus
>Could not connect to D-Bus server: org.freedesktop.DBus.Error.NotSupported:
>Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
OK, then what should a service executable do to connect to the system bus? Clearly this is done correctly for Linux and there's no platform-specific code in the code (KAuth framework) I'm working on, so we're back in dbus land.
On OS X, the service exec connects to the bus socket pointed to by a single env. variable (DBUS_LAUNCHD_SESSION_BUS_SOCKET) that's obtained in a dedicated function. I can hijack that variable to point to the system bus socket but it would of course be nicer to complete that function with a mechanism to check for and read DBUS_LAUNCHD_SYSTEM_BUS_SOCKET.
FWIW: googling DBUS_LAUNCHD_SYSTEM_BUS_SOCKET returns a single hit: https://github.com/tonyrog/dbus/blob/master/src/dbus_connection.erl
Apparently someone already encountered the need for connecting to a system bus on OS X in erlang code.
More information about the dbus