[gdm/gnome-3-18] Use -listen instead of -nolisten for new Xorg



commit 0831a7f11e06b28fc0f64c75a35f20e15ab19c9f
Author: Nathaniel Roach <nroach44 gmail com>
Date:   Tue Nov 10 09:11:08 2015 -0500

    Use -listen instead of -nolisten for new Xorg
    
    Newer Xorg versions don't listen to tcp sockets
    by default, so instead of explicitly passing
    -nolisten to disable tcp sockets by default,
    we need to explicitly pass -listen to enable
    tcp sockets when DisallowTCP=false.
    
    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>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750026

 configure.ac           |    8 ++++++++
 daemon/gdm-server.c    |   13 +++++++++++++
 daemon/gdm-x-session.c |   12 ++++++++++++
 3 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bedac99..7b6346c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1232,6 +1232,14 @@ else
 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_THAT_DEFAULTS_TO_LOCAL_ONLY], [], [XServer disables tcp access by default])
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl - Check for Xnest / Xephyr support
 dnl ---------------------------------------------------------------------------
 
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index eb7db0e..6357d34 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -320,11 +320,24 @@ gdm_server_resolve_command_line (GdmServer  *server,
                 argv[len++] = g_strdup (server->priv->display_seat_id);
         }
 
+        /* If we were compiled with Xserver >= 1.17 we need to specify
+         * '-listen tcp' as the X server dosen't listen on tcp sockets
+         * by default anymore. In older versions we need to pass
+         * -nolisten tcp to disable listening on tcp sockets.
+         */
+#ifdef HAVE_XSERVER_THAT_DEFAULTS_TO_LOCAL_ONLY
+        if (!server->priv->disable_tcp && ! query_in_arglist) {
+                argv[len++] = g_strdup ("-listen");
+                argv[len++] = g_strdup ("tcp");
+        }
+#else
         if (server->priv->disable_tcp && ! query_in_arglist) {
                 argv[len++] = g_strdup ("-nolisten");
                 argv[len++] = g_strdup ("tcp");
         }
 
+#endif
+
         if (vtarg != NULL && ! gotvtarg) {
                 argv[len++] = g_strdup (vtarg);
         }
diff --git a/daemon/gdm-x-session.c b/daemon/gdm-x-session.c
index 58646fa..624f67c 100644
--- a/daemon/gdm-x-session.c
+++ b/daemon/gdm-x-session.c
@@ -249,10 +249,22 @@ spawn_x_server (State        *state,
         g_ptr_array_add (arguments, "-auth");
         g_ptr_array_add (arguments, auth_file);
 
+        /* If we were compiled with Xserver >= 1.17 we need to specify
+         * '-listen tcp' as the X server dosen't listen on tcp sockets
+         * by default anymore. In older versions we need to pass
+         * -nolisten tcp to disable listening on tcp sockets.
+         */
+#ifdef HAVE_XSERVER_THAT_DEFAULTS_TO_LOCAL_ONLY
+        if (allow_remote_connections) {
+                g_ptr_array_add (arguments, "-listen");
+                g_ptr_array_add (arguments, "tcp");
+        }
+#else
         if (!allow_remote_connections) {
                 g_ptr_array_add (arguments, "-nolisten");
                 g_ptr_array_add (arguments, "tcp");
         }
+#endif
 
         g_ptr_array_add (arguments, "-background");
         g_ptr_array_add (arguments, "none");


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