> Now might be a good time to revive this patch which has been submitted
> before by Timo Juhani Lindfors (CCed):
> https://www.xpra.org/trac/attachment/ticket/172/X11-unix-domain-socket.patch
> 
> It would be very useful for us to avoid having to find a free display
> TCP port to use with the Vfb X11 server (Xdummy), we could just allocate
> a private socket as needed.
> 
> I suspect that the concerns will be security related. I don't mind
> coding and testing to ensure this new display mode cannot be abused, but
> at this point I am not entirely sure that any checks are actually needed.
Attached is an ugly minimal patch to xcb-util's xcb_parse_display and
xcb_open so that one can specify a full unix paths to the server's
socket, ie:
DISPLAY=:unix:/tmp/.X11-unix/X10 xlsclients
or if you use your own socket location (chroot or otherwise):
DISPLAY=:unix:/private/socket xlsclients

Are there any good reasons against it? (after a thorough clean up or
even a complete rewrite obviously). I can't think of a good one.
After all, the clients should be able to choose where they connect to
outside of the pre-defined /tmp/.X11-unix/ socket location without
having to resort to ugly tricks like this one (same result):
socat UNIX-LISTEN:/tmp/.X11-unix/:666 UNIX-CONNECT:/private/socket
DISPLAY=:666 xlsclients

Cheers
Antoine
--- a/src/xcb_util.c	2012-10-08 00:34:47.768142969 +0700
+++ b/src/xcb_util.c	2012-10-08 00:20:08.132927120 +0700
@@ -89,6 +86,22 @@
     if(!name)
         return 0;
 
+    fprintf(stderr, "_xcb_parse_display name=%s\n", name);
+    if(strncmp(name, ":unix:", 6) == 0) {
+        //take shortcut for simplicity
+        fprintf(stderr, "found unix domain socket: %s\n", name+6);
+        *protocol = malloc(5);
+        strncpy(*protocol, "unix", 5);
+        *host = malloc(strlen(name)-6);
+        if(!*host)
+            goto error_out;
+        strncpy(*host, name+6, strlen(name)-6);
+        *displayp = -1;			//we don't do numbers here...
+        if(screenp)
+            *screenp = screen;
+        return 1;
+    }
+
 #ifdef HAVE_LAUNCHD
     if(strncmp(name, "/tmp/launch", 11) == 0)
         slash = NULL;
@@ -207,6 +223,13 @@
     }
 #endif
 
+    if (*host == '/') {
+        file = malloc(strlen(host));
+        strncpy(file, host, strlen(host));
+        filelen = strlen(file);
+    }
+    else {
+
     filelen = strlen(base) + 1 + sizeof(display) * 3 + 1;
     file = malloc(filelen);
     if(file == NULL)
@@ -226,6 +249,7 @@
     }
     /* snprintf may truncate the file */
     filelen = MIN(actual_filelen, filelen - 1);
+    }
 #ifdef HAVE_ABSTRACT_SOCKETS
     fd = _xcb_open_abstract(protocol, file, filelen);
     if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
_______________________________________________
[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