#835846 cinnamon-session: don't run dbus-launch if XDG_RUNTIME_DIR/bus is available

#835846#5
Date:
2016-08-28 18:16:18 UTC
From:
To:
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.
cinnamon-session has code inherited from gnome-session that explicitly
runs dbus-launch if DBUS_SESSION_BUS_ADDRESS isn't set.

The major D-Bus implementations (libdbus, GDBus, sd-bus) now have a
fallback code path, before trying X11 autolaunch, when
DBUS_SESSION_BUS_ADDRESS is unset: if XDG_RUNTIME_DIR is set, and
XDG_RUNTIME_DIR/bus exists, is a socket and is owned by the
process's uid, then they will use it. In particular, dbus-user-session
sets up that situation.

For the moment, dbus-user-session does make sure DBUS_SESSION_BUS_ADDRESS
is set, to be nice to packages that don't have this fallback path.
However, I'd like to avoid requiring that in future, by adapting
the dbus-launch code in gnome-session and its forks to look for
XDG_RUNTIME_DIR/bus before trying dbus-launch.

It's probably best if this happens in gnome-session first (I'll
open the upstream bug after I've finished with this MBF), then gets
cherry-picked into the GNOME derivatives like Cinnamon.

Thanks,
    S

#835846#10
Date:
2022-06-17 18:29:36 UTC
From:
To:
Il 28/08/2016 20:16, Simon McVittie ha scritto:
Hi, from a fast search I not found change/remove use of dbus-launch
upstream and also in gnome-session. Have you did something related to
this I not found?

Thanks for any reply

#835846#15
Date:
2026-07-18 19:35:00 UTC
From:
To:
Thanks for report this, rechecked now, I did a fast test on xorg and
didn't cause problem but can be on wayland that will be more used from
next cinnamon version (out of experimental) so I started to report it
upstream.

#835846#20
Date:
2026-08-07 18:59:37 UTC
From:
To:
Hello,

Bug #835846 in cinnamon-session reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/cinnamon-team/cinnamon-session/-/commit/12281d6e45e3496b94a32cb97243c7bcd642407c
------------------------------------------------------------------------
d/patches: use the running user D-Bus session bus instead of dbus-launch

require_dbus_session() only looked at DBUS_SESSION_BUS_ADDRESS, so with
the variable unset cinnamon-session re-exec'd itself under `dbus-launch
--exit-with-session` even when the user already had a session bus
running on the well-known socket at $XDG_RUNTIME_DIR/bus. That starts a
second bus, splitting activatable services and portals across the two,
and with only dbus-user-session installed (no dbus-launch binary) the
session does not start at all. X11 logins usually escape this because
the display manager wraps the session in a script that exports
DBUS_SESSION_BUS_ADDRESS, but the Wayland session does not go through
those wrappers.

The first patch asks GDBus for the session bus address (it looks for the
socket at $XDG_RUNTIME_DIR/bus since GLib 2.50) and exports it, so every
child of the session ends up on the same bus; the dbus-launch fallback
stays for setups without a user bus. Same approach as gnome-session in
leader-main.c.

The second patch fixes the fallback itself: `if (!execvp (...))` was
never true, since execvp() returns only on failure and then always -1,
so the "No session bus and could not exec dbus-launch" error was dead
code and the session silently carried on with no bus at all. Both
patches come from linuxmint/cinnamon-session#212.

Tested in a sid chroot: with a bus on $XDG_RUNTIME_DIR/bus the patched
binary no longer execs dbus-launch while the archive build does; with no
user bus the dbus-launch fallback still starts a session bus as before;
and with neither, the session now aborts with the error message instead
of continuing without a bus.

Closes: #835846

Assisted-by: Claude Code:claude-opus-5
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/835846