[gdm/make-gdm-listen-better: 3/3] daemon: Support X servers built with -Dlisten_tcp=true




commit 552245e6433ade0dc5f49a4415a05fbda8cb0bb9
Author: Alan Coopersmith <alan coopersmith oracle com>
Date:   Thu Oct 7 18:22:11 2021 -0700

    daemon: Support X servers built with -Dlisten_tcp=true
    
    Xorg since version 1.17 doesn't listen to tcp sockets by default
    unless it's explicitly built with -Dlisten_tcp=true.
    
    GDM currently assumes X servers 1.17 and later are always built
    without specifying -Dlisten_tcp=true and doesn't work properly
    otherwise.
    
    This commit enhances GDM to better handle these non-standard builds by
    always passing '-nolisten tcp' on the command line when tcp should
    be disabled, and likewise always passing '-listen tcp' on the command
    line, assuming the X server is new enough to support it, when tcp
    should be enabled.
    
    Related #704

 daemon/gdm-server.c    | 21 +++++++++++----------
 daemon/gdm-x-session.c | 12 ++++++------
 meson.build            |  4 ++--
 3 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index 1ba00d458..e5d23521e 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -317,18 +317,19 @@ gdm_server_resolve_command_line (GdmServer  *server,
          * 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->disable_tcp && ! query_in_arglist) {
-                argv[len++] = g_strdup ("-listen");
-                argv[len++] = g_strdup ("tcp");
-        }
-#else
-        if (server->disable_tcp && ! query_in_arglist) {
-                argv[len++] = g_strdup ("-nolisten");
-                argv[len++] = g_strdup ("tcp");
-        }
+        if (!query_in_arglist) {
+                if (server->disable_tcp) {
+                        argv[len++] = g_strdup ("-nolisten");
+                        argv[len++] = g_strdup ("tcp");
+                }
 
+#ifdef HAVE_XSERVER_WITH_LISTEN
+                if (!server->disable_tcp) {
+                        argv[len++] = g_strdup ("-listen");
+                        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 5962da572..0b07ab5be 100644
--- a/daemon/gdm-x-session.c
+++ b/daemon/gdm-x-session.c
@@ -260,16 +260,16 @@ spawn_x_server (State        *state,
          * 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");
         }
+
+#ifdef HAVE_XSERVER_WITH_LISTEN
+        if (allow_remote_connections) {
+                g_ptr_array_add (arguments, "-listen");
+                g_ptr_array_add (arguments, "tcp");
+        }
 #endif
 
         g_ptr_array_add (arguments, "-background");
diff --git a/meson.build b/meson.build
index e0c56225b..dc16b9e71 100644
--- a/meson.build
+++ b/meson.build
@@ -71,7 +71,7 @@ x_deps = declare_dependency(
 )
 # Xserver 1.17 & later default to -nolisten and require -listen for remote access
 xserver_deps = dependency('xorg-server', version : '>=1.17', required : false)
-xserver_nolisten_default = xserver_deps.found()
+xserver_has_listen = xserver_deps.found()
 find_x_server_script = find_program('build-aux/find-x-server.sh', native: true)
 find_x_server_out = run_command(find_x_server_script).stdout().strip()
 if find_x_server_out != ''
@@ -227,7 +227,7 @@ conf.set('HAVE_PAM_SYSLOG', have_pam_syslog)
 conf.set('HAVE_KEYUTILS', keyutils_dep.found())
 conf.set('SUPPORTS_PAM_EXTENSIONS', pam_extensions_supported)
 conf.set('HAVE_SELINUX', libselinux_dep.found())
-conf.set('HAVE_XSERVER_THAT_DEFAULTS_TO_LOCAL_ONLY', xserver_nolisten_default)
+conf.set('HAVE_XSERVER_WITH_LISTEN', xserver_has_listen)
 conf.set('ENABLE_USER_DISPLAY_SERVER', get_option('user-display-server'))
 conf.set('ENABLE_SYSTEMD_JOURNAL', get_option('systemd-journal'))
 conf.set('ENABLE_WAYLAND_SUPPORT', get_option('wayland-support'))


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