From c0d86fbb0f92c78167d2c42ebf7cfcd1d69b4fa0 Mon Sep 17 00:00:00 2001 From: Fabio Fantoni Date: Fri, 7 Aug 2026 16:29:55 +0200 Subject: [PATCH 1/3] main.c: Use the existing user D-Bus session bus instead of spawning dbus-launch. require_dbus_session() only looked at DBUS_SESSION_BUS_ADDRESS, so with the variable unset it re-exec'd the session 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 (the default on systemd, and on elogind setups with dbus configured for the user bus). That starts a second bus, splitting activatable services and portals across the two, and on systems that ship no dbus-launch binary (Debian with only dbus-user-session installed) 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, so it depends on the display manager. Ask GDBus for the session bus address first: it looks for the socket at $XDG_RUNTIME_DIR/bus, and we export the address so every child of the session ends up on the same bus. The dbus-launch fallback stays for setups without a user bus, so nothing changes there. This is what gnome-session does in leader-main.c. Closes: https://github.com/linuxmint/cinnamon-session/issues/210 Assisted-by: Claude Code:claude-opus-5 --- cinnamon-session/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cinnamon-session/main.c b/cinnamon-session/main.c index 7730715..9f621b1 100644 --- a/cinnamon-session/main.c +++ b/cinnamon-session/main.c @@ -162,11 +162,23 @@ require_dbus_session (int argc, GError **error) { char **new_argv; + char *address; int i; if (g_getenv ("DBUS_SESSION_BUS_ADDRESS")) return TRUE; + /* Use the bus the user session already has (GDBus looks for the + * well-known socket at $XDG_RUNTIME_DIR/bus), rather than starting a + * second one that activated services and portals would be split + * across. Exporting the address keeps all our children on it. */ + address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SESSION, NULL, NULL); + if (address != NULL) { + g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, TRUE); + g_free (address); + return TRUE; + } + /* Just a sanity check to prevent infinite recursion if * dbus-launch fails to set DBUS_SESSION_BUS_ADDRESS */ From b173a87be509b1d26b7e0866db6ace63ddda5d95 Mon Sep 17 00:00:00 2001 From: Fabio Fantoni Date: Fri, 7 Aug 2026 16:47:52 +0200 Subject: [PATCH 2/3] build: Require GLib 2.50. The declared minimum, 2.37.3, has not matched the code for a long time: g_settings_schema_list_keys() in csm-autostart-app.c needs 2.46, g_strv_contains() and the g_autoptr/g_autofree macros need 2.44, and the GSubprocess and GVariantDict API need 2.40. Ask for 2.50 rather than 2.46: that is the version where g_dbus_address_get_for_bus_sync() started falling back to the well-known socket at $XDG_RUNTIME_DIR/bus, which is what lets the previous commit pick up the user session bus instead of spawning dbus-launch. Assisted-by: Claude Code:claude-opus-5 --- debian/control | 2 +- meson.build | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index d2ea80e..dd24323 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Build-Depends: libcanberra-dev, libcinnamon-desktop-dev (>= 6.0), libgl-dev, - libglib2.0-dev (>= 2.37.3), + libglib2.0-dev (>= 2.50.0), libgtk-3-dev (>= 3.0.0), libice-dev, libpango1.0-dev, diff --git a/meson.build b/meson.build index 0d2031c..1653efd 100644 --- a/meson.build +++ b/meson.build @@ -28,9 +28,9 @@ endif ################################################################################ # Dependencies -gio = dependency('gio-2.0') +gio = dependency('gio-2.0', version: '>=2.50.0') gtk3 = dependency('gtk+-3.0', version: '>=3.0.0') -glib = dependency('glib-2.0', version: '>=2.37.3') +glib = dependency('glib-2.0', version: '>=2.50.0') libcanberra = dependency('libcanberra') pango = dependency('pango') pangoxft = dependency('pangoxft', required: false) From 7bf151bcf3f82fa339477e5edd4a74c51a769884 Mon Sep 17 00:00:00 2001 From: Fabio Fantoni Date: Fri, 7 Aug 2026 19:44:24 +0200 Subject: [PATCH 3/3] main.c: Report the failure when dbus-launch cannot be executed. execvp() returns only when it failed, and then it always returns -1, so `if (!execvp (...))` was never true: the g_set_error() branch was dead code. Instead of failing with "No session bus and could not exec dbus-launch", require_dbus_session() fell through to the `return TRUE` marked "Should not be reached" and the session kept going with no session bus at all, silently, until something else broke further down. Call execvp() and treat its return as the failure it is. This is easier to hit than it looks on systems that ship no dbus-launch binary, and the previous commit does not change that: it only makes the fallback rarer, not the failure mode better. Assisted-by: Claude Code:claude-opus-5 --- cinnamon-session/main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cinnamon-session/main.c b/cinnamon-session/main.c index 9f621b1..64bb0bf 100644 --- a/cinnamon-session/main.c +++ b/cinnamon-session/main.c @@ -195,17 +195,15 @@ require_dbus_session (int argc, } new_argv[i + 2] = NULL; - if (!execvp ("dbus-launch", new_argv)) { - g_set_error (error, - G_SPAWN_ERROR, - G_SPAWN_ERROR_FAILED, - "No session bus and could not exec dbus-launch: %s", - g_strerror (errno)); - return FALSE; - } - - /* Should not be reached */ - return TRUE; + /* execvp() only returns on failure */ + execvp ("dbus-launch", new_argv); + + g_set_error (error, + G_SPAWN_ERROR, + G_SPAWN_ERROR_FAILED, + "No session bus and could not exec dbus-launch: %s", + g_strerror (errno)); + return FALSE; } /* Whether ~/.xinputrc (written by im-config / mintlocale-im) selects fcitx5.