diff options
author | Victor Kareh <[email protected]> | 2019-01-29 15:36:39 -0500 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2019-02-04 07:52:05 -0500 |
commit | 9c748b1c4f72d003d187337f6c4b71a7a56a2f22 (patch) | |
tree | 890dde011633de0495ba140916eec2bcd0297e52 /mate-session/gsm-manager.c | |
parent | 37d538eba3a6b36a6d739de4b7567a97203ada3a (diff) | |
download | mate-session-manager-9c748b1c4f72d003d187337f6c4b71a7a56a2f22.tar.bz2 mate-session-manager-9c748b1c4f72d003d187337f6c4b71a7a56a2f22.tar.xz |
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
Diffstat (limited to 'mate-session/gsm-manager.c')
-rw-r--r-- | mate-session/gsm-manager.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index 3ffcbf3..f9bdda0 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -889,6 +889,51 @@ _client_stop (const char *id, return FALSE; } +#ifdef HAVE_SYSTEMD +static void +maybe_restart_user_bus (GsmManager *manager) +{ + GsmSystemd *systemd; + GsmManagerPrivate *priv; + GDBusConnection *connection; + + g_autoptr(GVariant) reply = NULL; + g_autoptr(GError) error = NULL; + + priv = gsm_manager_get_instance_private (manager); + if (priv->dbus_disconnected) + return; + + systemd = gsm_get_systemd (); + + if (!gsm_systemd_is_last_session_for_user (systemd)) + return; + + connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + + if (error != NULL) { + g_debug ("GsmManager: failed to connect to session bus: %s", error->message); + return; + } + + reply = g_dbus_connection_call_sync (connection, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "TryRestartUnit", + g_variant_new ("(ss)", "dbus.service", "replace"), + NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + + if (error != NULL) { + g_debug ("GsmManager: reloading user bus failed: %s", error->message); + } +} +#endif + static void do_phase_exit (GsmManager *manager) { @@ -901,6 +946,10 @@ do_phase_exit (GsmManager *manager) NULL); } +#ifdef HAVE_SYSTEMD + maybe_restart_user_bus (manager); +#endif + end_phase (manager); } |