X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/e0e7dff87dc3f482da6ab00317664474b0f82995..227075f37bf2050ccadbefc091f7cceed78064dc:/unix/ux_x11.c diff --git a/unix/ux_x11.c b/unix/ux_x11.c index 7753c854..47d0ef5f 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -14,14 +14,22 @@ 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); if (!fp) return; /* assume no auth */ - localbuf = smalloc(maxsize); + localbuf = snewn(maxsize, char); while (1) { /*