X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fux_x11.c;h=e8d71959090efcbd287f3d40fe13fb5327a33aec;hb=d3b993a9c1d5e66f5432fa73f1435ada191142ca;hp=7753c85464d06b429613ea0f924c8f37edde05a5;hpb=86977efa810b9eabbee6f4a35ddc87e7e222f529;p=PuTTY.git diff --git a/unix/ux_x11.c b/unix/ux_x11.c index 7753c854..e8d71959 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -4,7 +4,9 @@ #include #include +#include #include "putty.h" +#include "ssh.h" void platform_get_x11_auth(char *display, int *protocol, unsigned char *data, int *datalen) @@ -13,22 +15,35 @@ void platform_get_x11_auth(char *display, int *protocol, char *command; int maxsize = *datalen; char *localbuf; + int proto = -1; - command = dupprintf("xauth list %s 2>/dev/null", display); + display = x11_display(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) + || !strncmp(display, "unix:", 5)) + command = dupprintf("xauth list %s 2>/dev/null", + strchr(display, ':')); + else + command = dupprintf("xauth list %s 2>/dev/null", display); + sfree(display); fp = popen(command, "r"); sfree(command); if (!fp) return; /* assume no auth */ - localbuf = smalloc(maxsize); + localbuf = snewn(maxsize, char); while (1) { /* * Read a line from stdin, and attempt to parse it into a * display name (ignored), auth protocol, and auth string. */ - int c, i, hexdigit, proto; + int c, i, hexdigit; char protoname[64]; /* Skip the display name. */