diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -40,7 +40,7 @@ | |||
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "includes.h" | 42 | #include "includes.h" |
43 | RCSID("$OpenBSD: ssh.c,v 1.181 2002/07/03 14:21:05 markus Exp $"); | 43 | RCSID("$OpenBSD: ssh.c,v 1.182 2002/07/19 17:42:40 stevesk Exp $"); |
44 | 44 | ||
45 | #include <openssl/evp.h> | 45 | #include <openssl/evp.h> |
46 | #include <openssl/err.h> | 46 | #include <openssl/err.h> |
@@ -734,11 +734,19 @@ x11_get_proto(char **_proto, char **_data) | |||
734 | FILE *f; | 734 | FILE *f; |
735 | int got_data = 0, i; | 735 | int got_data = 0, i; |
736 | char *display; | 736 | char *display; |
737 | struct stat st; | ||
737 | 738 | ||
738 | *_proto = proto; | 739 | *_proto = proto; |
739 | *_data = data; | 740 | *_data = data; |
740 | proto[0] = data[0] = '\0'; | 741 | proto[0] = data[0] = '\0'; |
741 | if (options.xauth_location && (display = getenv("DISPLAY"))) { | 742 | if (!options.xauth_location || |
743 | (stat(options.xauth_location, &st) == -1)) { | ||
744 | debug("No xauth program."); | ||
745 | } else { | ||
746 | if ((display = getenv("DISPLAY")) == NULL) { | ||
747 | debug("x11_get_proto: DISPLAY not set"); | ||
748 | return; | ||
749 | } | ||
742 | /* Try to get Xauthority information for the display. */ | 750 | /* Try to get Xauthority information for the display. */ |
743 | if (strncmp(display, "localhost:", 10) == 0) | 751 | if (strncmp(display, "localhost:", 10) == 0) |
744 | /* | 752 | /* |
@@ -753,7 +761,7 @@ x11_get_proto(char **_proto, char **_data) | |||
753 | else | 761 | else |
754 | snprintf(line, sizeof line, "%s list %.200s 2>" | 762 | snprintf(line, sizeof line, "%s list %.200s 2>" |
755 | _PATH_DEVNULL, options.xauth_location, display); | 763 | _PATH_DEVNULL, options.xauth_location, display); |
756 | debug2("x11_get_proto %s", line); | 764 | debug2("x11_get_proto: %s", line); |
757 | f = popen(line, "r"); | 765 | f = popen(line, "r"); |
758 | if (f && fgets(line, sizeof(line), f) && | 766 | if (f && fgets(line, sizeof(line), f) && |
759 | sscanf(line, "%*s %511s %511s", proto, data) == 2) | 767 | sscanf(line, "%*s %511s %511s", proto, data) == 2) |
@@ -772,6 +780,7 @@ x11_get_proto(char **_proto, char **_data) | |||
772 | if (!got_data) { | 780 | if (!got_data) { |
773 | u_int32_t rand = 0; | 781 | u_int32_t rand = 0; |
774 | 782 | ||
783 | log("Warning: No xauth data; using fake authentication data for X11 forwarding."); | ||
775 | strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto); | 784 | strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto); |
776 | for (i = 0; i < 16; i++) { | 785 | for (i = 0; i < 16; i++) { |
777 | if (i % 4 == 0) | 786 | if (i % 4 == 0) |