This disables tcp and unix listen ports by default (the unix port is
the non-abstract /tmp/.X11-unix port that xcb doesn't use). Then, it
uses a new xtrans interface, TRANS(Listen), to provide a command line
option to re-enable those if desired.

Signed-off-by: Keith Packard <[email protected]>
---
 os/utils.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/os/utils.c b/os/utils.c
index c83f77d..ff1806b 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -646,6 +646,12 @@ VerifyDisplayName(const char *d)
     return 1;
 }
 
+static const char *defaultNoListenList[] = {
+    "tcp",
+    "unix",
+    NULL
+};
+
 /*
  * This function parses the command line. Handles device-independent fields
  * and allows ddx to handle additional fields.  It is not allowed to modify
@@ -664,6 +670,12 @@ ProcessCommandLine(int argc, char *argv[])
     PartialNetwork = TRUE;
 #endif
 
+    for (i = 0; defaultNoListenList[i] != NULL; i++) {
+        if (_XSERVTransNoListen(defaultNoListenList[i]))
+                    ErrorF("Failed to disable listen for %s transport",
+                           defaultNoListenList[i]);
+    }
+
     for (i = 1; i < argc; i++) {
         /* call ddx first, so it can peek/override if it wants */
         if ((skip = ddxProcessArgument(argc, argv, i))) {
@@ -849,6 +861,15 @@ ProcessCommandLine(int argc, char *argv[])
             else
                 UseMsg();
         }
+        else if (strcmp(argv[i], "-listen") == 0) {
+            if (++i < argc) {
+                if (_XSERVTransListen(argv[i]))
+                    ErrorF("Failed to enable listen for %s transport",
+                           argv[i]);
+            }
+            else
+                UseMsg();
+        }
         else if (strcmp(argv[i], "-noreset") == 0) {
             dispatchExceptionAtReset = 0;
         }
-- 
2.1.0

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to