[gdm/wip/wayland-at-login-screen: 65/68] display: only add user authorization if connected to display



commit 3caccba0091c55b20c8a8aa947e3eb04c230db28
Author: Ray Strode <rstrode redhat com>
Date:   Tue Feb 17 17:22:57 2015 -0500

    display: only add user authorization if connected to display
    
    If we aren't connected to the display then we can't give
    the user access to it,(and we don't need to anyway)
    
    This commit adds a new is-connected property to GdmDisplay and
    changes the code to never give a user authorization if we
    aren't connected.

 daemon/gdm-display.c |   15 +++++++++++++++
 daemon/gdm-manager.c |   27 ++++++++++++++++-----------
 2 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 6b2a95a..4069c6b 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -106,6 +106,7 @@ enum {
         PROP_X11_DISPLAY_NAME,
         PROP_X11_COOKIE,
         PROP_X11_AUTHORITY_FILE,
+        PROP_IS_CONNECTED,
         PROP_IS_LOCAL,
         PROP_LAUNCH_ENVIRONMENT,
         PROP_IS_INITIAL,
@@ -1001,6 +1002,9 @@ gdm_display_get_property (GObject        *object,
         case PROP_IS_LOCAL:
                 g_value_set_boolean (value, self->priv->is_local);
                 break;
+        case PROP_IS_CONNECTED:
+                g_value_set_boolean (value, self->priv->x11_display != NULL);
+                break;
         case PROP_LAUNCH_ENVIRONMENT:
                 g_value_set_object (value, self->priv->launch_environment);
                 break;
@@ -1302,6 +1306,13 @@ gdm_display_class_init (GdmDisplayClass *klass)
                                                                TRUE,
                                                                G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
         g_object_class_install_property (object_class,
+                                         PROP_IS_CONNECTED,
+                                         g_param_spec_boolean ("is-connected",
+                                                               NULL,
+                                                               NULL,
+                                                               TRUE,
+                                                               G_PARAM_READABLE));
+        g_object_class_install_property (object_class,
                                          PROP_HAVE_EXISTING_USER_ACCOUNTS,
                                          g_param_spec_boolean ("have-existing-user-accounts",
                                                                NULL,
@@ -1772,6 +1783,10 @@ gdm_display_connect (GdmDisplay *self)
                 ret = TRUE;
         }
 
+        if (ret == TRUE) {
+                g_object_notify (G_OBJECT (self), "is-connected");
+        }
+
         return ret;
 }
 
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index 42aa635..6c030b8 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -1573,21 +1573,26 @@ start_user_session (GdmManager *manager,
         if (display != NULL) {
                 char *auth_file;
                 const char *username;
+                gboolean is_connected = FALSE;
 
-                auth_file = NULL;
-                username = gdm_session_get_username (operation->session);
-                gdm_display_add_user_authorization (display,
-                                                    username,
-                                                    &auth_file,
-                                                    NULL);
+                g_object_get (G_OBJECT (display), "is-connected", &is_connected, NULL);
 
-                g_assert (auth_file != NULL);
+                if (is_connected) {
+                        auth_file = NULL;
+                        username = gdm_session_get_username (operation->session);
+                        gdm_display_add_user_authorization (display,
+                                                            username,
+                                                            &auth_file,
+                                                            NULL);
+
+                        g_assert (auth_file != NULL);
 
-                g_object_set (operation->session,
-                              "user-x11-authority-file", auth_file,
-                              NULL);
+                        g_object_set (operation->session,
+                                      "user-x11-authority-file", auth_file,
+                                      NULL);
 
-                g_free (auth_file);
+                        g_free (auth_file);
+                }
         }
 
         gdm_session_start_session (operation->session,


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