- 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 = 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;
- char protoname[64];
-
- /* Skip the display name. */
- while (c = getc(fp), c != EOF && c != '\n' && !isspace(c));
- if (c == EOF) break;
- if (c == '\n') continue;
-
- /* Skip white space. */
- while (c != EOF && c != '\n' && isspace(c))
- c = getc(fp);
- if (c == EOF) break;
- if (c == '\n') continue;
-
- /* Read the auth protocol name, and see if it matches any we
- * know about. */
- i = 0;
- while (c != EOF && c != '\n' && !isspace(c)) {
- if (i < lenof(protoname)-1) protoname[i++] = c;
- c = getc(fp);
- }
- protoname[i] = '\0';
-
- for (i = X11_NO_AUTH; ++i < X11_NAUTHS ;) {
- if (!strcmp(protoname, x11_authnames[i]))
- break;
- }
- if (i >= X11_NAUTHS || i <= proto) {
- /* Unrecognised protocol name, or a worse one than we already have.
- * Skip this line. */
- while (c != EOF && c != '\n')
- c = getc(fp);
- if (c == EOF) break;
- }
- proto = i;
+ if (!disp->unixdomain && sk_address_is_local(disp->addr)) {
+ sk_addr_free(disp->addr);
+ disp->unixdomain = TRUE;
+ disp->addr = platform_get_x11_unix_address(NULL, disp->displaynum);
+ disp->realhost = dupprintf("unix:%d", disp->displaynum);
+ disp->port = 0;
+ }