As described in <https://lists.debian.org/debian-devel/2016/08/msg00554.html>
I'm trying to reduce how much dbus-launch is used in Debian.
mopidy-dleyna currently runs dbus-launch in both syncevo-http-server.py
and test/dbus-session.sh if DBUS_SESSION_BUS_ADDRESS is unset.
One issue with this approach in syncevo-http-server.py is that it
second-guesses how the D-Bus client implementation itself will find
the session bus. In recent libdbus and GDBus, the fallback behaviour if
DBUS_SESSION_BUS_ADDRESS is unset is to look for $XDG_RUNTIME_DIR/bus:
if the environment variable is set, that directory contains ./bus,
and ./bus is a socket owned by the current uid, then libdbus and GDBus
will automatically use it. In particular, the dbus-user-session Debian
package sets up this situation. syncevo-http-server.py should not run
dbus-launch without first looking for that socket.
Another issue with the approach this package has taken, in both
places, is that it relies on dbus-launch, which is X11-specific
legacy code that does several things, none of them particularly well.
This Flatpak commit illustrates how eval `dbus-launch` can be replaced
by invoking dbus-daemon directly, avoiding the X11-specific dbus-launch:
<https://github.com/flatpak/flatpak/commit/6cc8062cfb3f9410d54a27e7ccca77c103e441e8>.
It is possible to send both the address and the pid to stdout
("--print-address=1 --print-pid=1") if that would be easier to deal with;
their order is undocumented but predictable, and I don't intend to break
it in future D-Bus releases. In particular, this would be appropriate
for test/dbus-session.sh to do.
One way to deal with syncevo-http-server.py would be for this package to
stop trying to compensate for a missing session bus address at all. On
systems with $XDG_RUNTIME_DIR/bus, it would "just work" anyway; or when
run under X11 (even with no dbus-daemon running), X11 autolaunching
would create a dbus-daemon anyway; or if it is being run in a non-GUI
environment like cron, its documentation could mention that this may
require either setting DISPLAY, or running
dbus-run-session -- syncevo-http-server ...
which has been available since dbus 1.8, and automatically cleans up
the dbus-daemon after syncevo-http-server terminates (successfully
or not). It is not really syncevo-http-server.py's job to set up D-Bus.
In Debian, a dependency on default-dbus-session-bus | dbus-session-bus
is an appropriate way to make sure that at least X11 login sessions,
and sometimes non-X11 login sessions too, will have a D-Bus session
bus available without the need to take special steps.
This is really mostly an upstream bug. If you forward it upstream, please
quote the full text of this bug report and let upstream make their
own decisions.
Thanks,
S