Blob Blame History Raw
From 9367cdcb777cabacc5cb436155e4ab7c32dc74ef Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Fri, 31 Mar 2017 14:52:23 -0400
Subject: [PATCH 07/13] xdmcp-display: don't set MANAGED until we've connected

We don't want to start the greeter session until we've
successfully connected to the display ourselves!

This prevents a race where session processes may inadvertently
 get the initial connection to the display server, causing
premature resets.
---
 daemon/gdm-xdmcp-display.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/daemon/gdm-xdmcp-display.c b/daemon/gdm-xdmcp-display.c
index c9f9c3d2..630844f2 100644
--- a/daemon/gdm-xdmcp-display.c
+++ b/daemon/gdm-xdmcp-display.c
@@ -166,80 +166,79 @@ gdm_xdmcp_display_prepare (GdmDisplay *display)
                       NULL);
 
         if (launch_environment == NULL) {
                 launch_environment = gdm_create_greeter_launch_environment (display_name,
                                                                             seat_id,
                                                                             NULL,
                                                                             hostname,
                                                                             FALSE);
                 g_object_set (self, "launch-environment", launch_environment, NULL);
                 g_object_unref (launch_environment);
         }
 
         if (!gdm_display_create_authority (display)) {
                 g_warning ("Unable to set up access control for display %s",
                            display_name);
                 return FALSE;
         }
 
         return GDM_DISPLAY_CLASS (gdm_xdmcp_display_parent_class)->prepare (display);
 }
 
 static gboolean
 idle_connect_to_display (GdmXdmcpDisplay *self)
 {
         gboolean res;
 
         self->priv->connection_attempts++;
 
         res = gdm_display_connect (GDM_DISPLAY (self));
         if (res) {
+                g_object_set (G_OBJECT (self), "status", GDM_DISPLAY_MANAGED, NULL);
         } else {
                 if (self->priv->connection_attempts >= MAX_CONNECT_ATTEMPTS) {
                         g_warning ("Unable to connect to display after %d tries - bailing out", self->priv->connection_attempts);
                         gdm_display_unmanage (GDM_DISPLAY (self));
                         return FALSE;
                 }
                 return TRUE;
         }
 
         return FALSE;
 }
 
 static void
 gdm_xdmcp_display_manage (GdmDisplay *display)
 {
         GdmXdmcpDisplay *self = GDM_XDMCP_DISPLAY (display);
 
         g_timeout_add (500, (GSourceFunc)idle_connect_to_display, self);
-
-        g_object_set (G_OBJECT (self), "status", GDM_DISPLAY_MANAGED, NULL);
 }
 
 static void
 gdm_xdmcp_display_class_init (GdmXdmcpDisplayClass *klass)
 {
         GObjectClass    *object_class = G_OBJECT_CLASS (klass);
         GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
 
         object_class->get_property = gdm_xdmcp_display_get_property;
         object_class->set_property = gdm_xdmcp_display_set_property;
 
         display_class->prepare = gdm_xdmcp_display_prepare;
         display_class->manage = gdm_xdmcp_display_manage;
 
         g_type_class_add_private (klass, sizeof (GdmXdmcpDisplayPrivate));
 
         g_object_class_install_property (object_class,
                                          PROP_REMOTE_ADDRESS,
                                          g_param_spec_boxed ("remote-address",
                                                              "Remote address",
                                                              "Remote address",
                                                              GDM_TYPE_ADDRESS,
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
         g_object_class_install_property (object_class,
                                          PROP_SESSION_NUMBER,
                                          g_param_spec_int ("session-number",
                                                            "session-number",
                                                            "session-number",
                                                            G_MININT,
-- 
2.12.0