diff options
author | infirit <[email protected]> | 2014-11-04 20:38:26 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-04 22:08:50 +0100 |
commit | f3ad046b9abf2d52514527e483c92c4b791ab94c (patch) | |
tree | 59152c98ad943b936cf24eb0dc789d0891b3e690 | |
parent | 5fe70eb9aa653c1218d9e420d369819e7d54a9c8 (diff) | |
download | mate-session-manager-f3ad046b9abf2d52514527e483c92c4b791ab94c.tar.bz2 mate-session-manager-f3ad046b9abf2d52514527e483c92c4b791ab94c.tar.xz |
gsm: Also support disable-log-out for Shutdown/CanShutdown dbus methods
On top of that, be a bit paranoid and ensure we don't log out in
end_phase() by checking the lockdown setting there too.
Based on gnome-session-commit: 107cfa7a4f6f43698407772e31472d742bdb219f
From: Vincent Untz <[email protected]>
-rw-r--r-- | mate-session/gsm-manager.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/mate-session/gsm-manager.c b/mate-session/gsm-manager.c index a880fb3..c8af33a 100644 --- a/mate-session/gsm-manager.c +++ b/mate-session/gsm-manager.c @@ -175,6 +175,8 @@ static void gsm_manager_class_init (GsmManagerClass *klass); static void gsm_manager_init (GsmManager *manager); static void gsm_manager_finalize (GObject *object); +static gboolean _log_out_is_locked_down (GsmManager *manager); + static void _handle_client_end_session_response (GsmManager *manager, GsmClient *client, gboolean is_ok, @@ -523,6 +525,8 @@ gsm_manager_quit (GsmManager *manager) static void end_phase (GsmManager *manager) { + gboolean start_next_phase = TRUE; + g_debug ("GsmManager: ending phase %s\n", phase_num_to_name (manager->priv->phase)); @@ -547,25 +551,32 @@ end_phase (GsmManager *manager) case GSM_MANAGER_PHASE_PANEL: case GSM_MANAGER_PHASE_DESKTOP: case GSM_MANAGER_PHASE_APPLICATION: + break; case GSM_MANAGER_PHASE_RUNNING: + if (_log_out_is_locked_down (manager)) { + g_warning ("Unable to logout: Logout has been locked down"); + start_next_phase = FALSE; + } + break; case GSM_MANAGER_PHASE_QUERY_END_SESSION: - manager->priv->phase++; - start_phase (manager); break; case GSM_MANAGER_PHASE_END_SESSION: - if (auto_save_is_enabled (manager)) { + if (auto_save_is_enabled (manager)) maybe_save_session (manager); - } - manager->priv->phase++; - start_phase (manager); break; case GSM_MANAGER_PHASE_EXIT: + start_next_phase = FALSE; gsm_manager_quit (manager); break; default: g_assert_not_reached (); break; } + + if (start_next_phase) { + manager->priv->phase++; + start_phase (manager); + } } static void @@ -3327,6 +3338,14 @@ gsm_manager_shutdown (GsmManager *manager, return FALSE; } + if (_log_out_is_locked_down (manager)) { + g_set_error (error, + GSM_MANAGER_ERROR, + GSM_MANAGER_ERROR_LOCKED_DOWN, + "Logout has been locked down"); + return FALSE; + } + show_shutdown_dialog (manager); return TRUE; @@ -3365,10 +3384,11 @@ gsm_manager_can_shutdown (GsmManager *manager, else { #endif consolekit = gsm_get_consolekit (); - *shutdown_available = gsm_consolekit_can_stop (consolekit) - || gsm_consolekit_can_restart (consolekit) - || can_suspend - || can_hibernate; + *shutdown_available = !_log_out_is_locked_down (manager) && + (gsm_consolekit_can_stop (consolekit) + || gsm_consolekit_can_restart (consolekit) + || can_suspend + || can_hibernate); g_object_unref (consolekit); #ifdef HAVE_SYSTEMD } |