--- gdm-2.26.1.org/daemon/gdm-slave.c	2009-10-25 21:19:16.000000000 +0100
+++ gdm-2.26.1/daemon/gdm-slave.c	2009-10-25 21:17:56.000000000 +0100
@@ -115,6 +115,8 @@
 
 static guint signals [LAST_SIGNAL] = { 0, };
 
+static Bool     x_error_occurred = False;
+
 static void     gdm_slave_class_init    (GdmSlaveClass *klass);
 static void     gdm_slave_init          (GdmSlave      *slave);
 static void     gdm_slave_finalize      (GObject       *object);
@@ -432,12 +434,22 @@
         }
 }
 
+static int
+x_error_ignore_handler(Display * dpy, XErrorEvent * errev)
+{
+        x_error_occurred = True;
+
+        return(0);
+}
+
 gboolean
 gdm_slave_connect_to_x11_display (GdmSlave *slave)
 {
         gboolean ret;
         sigset_t mask;
         sigset_t omask;
+        int      res;
+        int      (*old_handler)(Display *, XErrorEvent *);
 
         ret = FALSE;
 
@@ -495,8 +507,27 @@
                 host_entries[1].address = (char *) &si_entries[1];
                 host_entries[1].length = sizeof (XServerInterpretedAddress);
 
-                XAddHosts (slave->priv->server_display, host_entries,
-                           G_N_ELEMENTS (host_entries));
+                /* XAddHost might fail with older clients. Maybe this is no
+                 * problem, so we try to proceed and only log a warning.
+                 * To suppress but notify the X error, a bit of care must
+                 * be taken
+                 */
+                res = XSync(slave->priv->server_display, False);
+
+                x_error_occurred = False;
+                old_handler = XSetErrorHandler(x_error_ignore_handler);
+
+                res = XAddHosts (slave->priv->server_display, host_entries, 1);
+
+                res = XAddHosts (slave->priv->server_display, host_entries + 1, 1);
+
+                res = XSync(slave->priv->server_display, False);
+
+                XSetErrorHandler(old_handler);
+
+                if(x_error_occurred)
+                        g_warning ("Failed to give slave programs access to the display. Trying to proceed.");
+
         }
 
         return ret;
