Hack around an oddity in X display names and xauth.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 11 Jan 2003 09:46:50 +0000 (09:46 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 11 Jan 2003 09:46:50 +0000 (09:46 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@2538 cda61777-01e9-0310-a592-d414129be87e

unix/ux_x11.c

index 7753c85..61b4f04 100644 (file)
@@ -14,7 +14,15 @@ void platform_get_x11_auth(char *display, int *protocol,
     int maxsize = *datalen;
     char *localbuf;
 
-    command = dupprintf("xauth list %s 2>/dev/null", display);
+    /*
+     * Normally we should run `xauth list DISPLAYNAME'. However,
+     * there's an oddity when the display is local: the display
+     * `localhost:0' (or `:0') should become just `:0'.
+     */
+    if (!strncmp(display, "localhost:", 10))
+       command = dupprintf("xauth list %s 2>/dev/null", display+9);
+    else
+       command = dupprintf("xauth list %s 2>/dev/null", display);
     fp = popen(command, "r");
     sfree(command);