Newer Xorg versions use -nolisten by default, so we need to set
listen for users who set DisallowTCP=false.

However, older versions don't support the -listen flag, so we check the version
and if it's >= 1.17 then we specify -listen tcp
Signed-off-by: Nathaniel Roach <nroach44@gmail.com>
---

--- gdm3-3.18.0-old/configure.ac
+++ gdm3-3.18.0/configure.ac
@@ -1235,6 +1235,14 @@
 fi
 
 dnl ---------------------------------------------------------------------------
+dnl - Check if Xorg is new enough to require '-listen tcp' (1.17)
+dnl ---------------------------------------------------------------------------
+
+if $PKG_CONFIG --atleast-version=1.17 xorg-server; then
+   AC_DEFINE([HAVE_XSERVER_DEFAULT_NOLISTEN], [], [XServer by default uses -nolisten])
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl - Check for Xnest / Xephyr support
 dnl ---------------------------------------------------------------------------
 
--- gdm3-3.18.0-old/daemon/gdm-server.c
+++ gdm3-3.18.0/daemon/gdm-server.c
@@ -326,6 +326,18 @@
                 argv[len++] = g_strdup ("-nolisten");
                 argv[len++] = g_strdup ("tcp");
         }
+
+        /* If we were compiled with Xserver >= 1.17 we need to specify
+         * '-listen tcp' as '-nolisten' is default, and listen is not valid for
+         * newer versions.
+         * Don't have the logit on the nolisten as it still works on both 
+         * versions and saves complexity */
+        #ifdef HAVE_XSERVER_DEFAULT_NOLISTEN
+        if (!server->priv->disable_tcp && ! query_in_arglist) {
+                argv[len++] = g_strdup ("-listen");
+                argv[len++] = g_strdup ("tcp");
+        }
+        #endif
 
         if (vtarg != NULL && ! gotvtarg) {
                 argv[len++] = g_strdup (vtarg);

--- gdm3-3.18.0-old/daemon/gdm-x-session.c
+++ gdm3-3.18.0/daemon/gdm-x-session.c
@@ -254,6 +254,18 @@
                 g_ptr_array_add (arguments, "tcp");
         }
 
+        /* If we were compiled with Xserver >= 1.17 we need to specify
+         * '-listen tcp' as '-nolisten' is default, and listen is not valid for
+         * newer versions.
+         * Don't have the logit on the nolisten as it still works on both 
+         * versions and saves complexity */
+        #ifdef HAVE_XSERVER_DEFAULT_NOLISTEN
+        if (allow_remote_connections) {
+                g_ptr_array_add (arguments, "-listen");
+                g_ptr_array_add (arguments, "tcp");
+        }
+        #endif
+
         g_ptr_array_add (arguments, "-background");
         g_ptr_array_add (arguments, "none");
 

