[gnome-session] manager: honor disable-log-out lockdown configuration



commit 1e3e0b475cfd352d4abe7ace4ee5a40be04a8b42
Author: Ray Strode <rstrode redhat com>
Date:   Mon Mar 21 08:31:37 2011 -0400

    manager: honor disable-log-out lockdown configuration
    
    Right now we have a disable-log-out configuration key in the
    org.gnome.desktop.lockdown schema that we superficially support in the
    UI, but disregard when servicing the dbus session manager interface.
    
    This commit makes gnome-session prohibit log out via its D-Bus
    interface (and XSMP), if log out is locked down.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645419

 gnome-session/gsm-manager.c |   26 ++++++++++++++++++++++++++
 gnome-session/gsm-manager.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 20dceca..f967d2d 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -86,6 +86,9 @@
 #define SCREENSAVER_SCHEMA        "org.gnome.desktop.screensaver"
 #define KEY_SLEEP_LOCK            "lock-enabled"
 
+#define LOCKDOWN_SCHEMA           "org.gnome.desktop.lockdown"
+#define KEY_DISABLE_LOG_OUT       "disable-log-out"
+
 static void app_registered (GsmApp     *app, GsmManager *manager);
 
 typedef enum
@@ -135,6 +138,7 @@ struct GsmManagerPrivate
         GSettings              *settings;
         GSettings              *session_settings;
         GSettings              *screensaver_settings;
+        GSettings              *lockdown_settings;
 
         DBusGProxy             *bus_proxy;
         DBusGConnection        *connection;
@@ -214,6 +218,7 @@ gsm_manager_error_get_type (void)
                         ENUM_ENTRY (GSM_MANAGER_ERROR_ALREADY_REGISTERED, "AlreadyRegistered"),
                         ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_REGISTERED, "NotRegistered"),
                         ENUM_ENTRY (GSM_MANAGER_ERROR_INVALID_OPTION, "InvalidOption"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_LOCKED_DOWN, "LockedDown"),
                         { 0, 0, 0 }
                 };
 
@@ -2467,6 +2472,11 @@ gsm_manager_dispose (GObject *object)
                 manager->priv->screensaver_settings = NULL;
         }
 
+        if (manager->priv->lockdown_settings) {
+                g_object_unref (manager->priv->lockdown_settings);
+                manager->priv->lockdown_settings = NULL;
+        }
+
         if (manager->priv->up_client != NULL) {
                 g_object_unref (manager->priv->up_client);
                 manager->priv->up_client = NULL;
@@ -2647,6 +2657,7 @@ gsm_manager_init (GsmManager *manager)
         manager->priv->settings = g_settings_new (GSM_MANAGER_SCHEMA);
         manager->priv->session_settings = g_settings_new (SESSION_SCHEMA);
         manager->priv->screensaver_settings = g_settings_new (SCREENSAVER_SCHEMA);
+        manager->priv->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
 
         manager->priv->inhibitors = gsm_store_new ();
         g_signal_connect (manager->priv->inhibitors,
@@ -3269,6 +3280,13 @@ gsm_manager_set_phase (GsmManager      *manager,
         return (TRUE);
 }
 
+static gboolean
+_log_out_is_locked_down (GsmManager *manager)
+{
+        return g_settings_get_boolean (manager->priv->lockdown_settings,
+                                       KEY_DISABLE_LOG_OUT);
+}
+
 gboolean
 gsm_manager_shutdown (GsmManager *manager,
                       GError    **error)
@@ -3343,6 +3361,14 @@ gsm_manager_logout (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;
+        }
+
         switch (logout_mode) {
         case GSM_MANAGER_LOGOUT_MODE_NORMAL:
         case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION:
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
index 704f157..73b6c5e 100644
--- a/gnome-session/gsm-manager.h
+++ b/gnome-session/gsm-manager.h
@@ -94,6 +94,7 @@ typedef enum
         GSM_MANAGER_ERROR_ALREADY_REGISTERED,
         GSM_MANAGER_ERROR_NOT_REGISTERED,
         GSM_MANAGER_ERROR_INVALID_OPTION,
+        GSM_MANAGER_ERROR_LOCKED_DOWN,
         GSM_MANAGER_NUM_ERRORS
 } GsmManagerError;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]