Skip to content

Commit 9c748b1

Browse files
committed
manager: restart user bus if last graphical session
There are desktop services (such as goa-daemon, e-d-s, etc) that don't open the display, but rely on dbus-daemon to scope the session. These days dbus-daemon is a user bus, not a sesssion, bus which leaves these services alive after log out. This commit checks to see if we're the last desktop session for the user at log out time, and if so, restarts the dbus daemon. This will lead to existing clients getting booted and die, but allow user bus clients that want to outlive a session to stick around if they so desire. Longer term, clients should stop relying on the session bus to define their lifetime. https://bugzilla.gnome.org/show_bug.cgi?id=764029 Adapted from https://gitlab.gnome.org/GNOME/gnome-session/commit/97d1cf5
1 parent 37d538e commit 9c748b1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

‎mate-session/gsm-manager.c‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,51 @@ _client_stop (const char *id,
889889
return FALSE;
890890
}
891891

892+
#ifdef HAVE_SYSTEMD
893+
static void
894+
maybe_restart_user_bus (GsmManager *manager)
895+
{
896+
GsmSystemd *systemd;
897+
GsmManagerPrivate *priv;
898+
GDBusConnection *connection;
899+
900+
g_autoptr(GVariant) reply = NULL;
901+
g_autoptr(GError) error = NULL;
902+
903+
priv = gsm_manager_get_instance_private (manager);
904+
if (priv->dbus_disconnected)
905+
return;
906+
907+
systemd = gsm_get_systemd ();
908+
909+
if (!gsm_systemd_is_last_session_for_user (systemd))
910+
return;
911+
912+
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
913+
914+
if (error != NULL) {
915+
g_debug ("GsmManager: failed to connect to session bus: %s", error->message);
916+
return;
917+
}
918+
919+
reply = g_dbus_connection_call_sync (connection,
920+
"org.freedesktop.systemd1",
921+
"/org/freedesktop/systemd1",
922+
"org.freedesktop.systemd1.Manager",
923+
"TryRestartUnit",
924+
g_variant_new ("(ss)", "dbus.service", "replace"),
925+
NULL,
926+
G_DBUS_CALL_FLAGS_NONE,
927+
-1,
928+
NULL,
929+
&error);
930+
931+
if (error != NULL) {
932+
g_debug ("GsmManager: reloading user bus failed: %s", error->message);
933+
}
934+
}
935+
#endif
936+
892937
static void
893938
do_phase_exit (GsmManager *manager)
894939
{
@@ -901,6 +946,10 @@ do_phase_exit (GsmManager *manager)
901946
NULL);
902947
}
903948

949+
#ifdef HAVE_SYSTEMD
950+
maybe_restart_user_bus (manager);
951+
#endif
952+
904953
end_phase (manager);
905954
}
906955

0 commit comments

Comments
 (0)