diff options
Diffstat (limited to 'channels.c')
-rw-r--r-- | channels.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/channels.c b/channels.c index 8d6d87ae3..539dff3a5 100644 --- a/channels.c +++ b/channels.c | |||
@@ -16,7 +16,7 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include "includes.h" | 18 | #include "includes.h" |
19 | RCSID("$Id: channels.c,v 1.12 1999/12/13 23:47:15 damien Exp $"); | 19 | RCSID("$Id: channels.c,v 1.13 1999/12/21 00:18:08 damien Exp $"); |
20 | 20 | ||
21 | #include "ssh.h" | 21 | #include "ssh.h" |
22 | #include "packet.h" | 22 | #include "packet.h" |
@@ -1159,10 +1159,48 @@ x11_create_display_inet(int screen_number, int x11_display_offset) | |||
1159 | return NULL; | 1159 | return NULL; |
1160 | } | 1160 | } |
1161 | /* Set up a suitable value for the DISPLAY variable. */ | 1161 | /* Set up a suitable value for the DISPLAY variable. */ |
1162 | |||
1162 | if (gethostname(hostname, sizeof(hostname)) < 0) | 1163 | if (gethostname(hostname, sizeof(hostname)) < 0) |
1163 | fatal("gethostname: %.100s", strerror(errno)); | 1164 | fatal("gethostname: %.100s", strerror(errno)); |
1165 | |||
1166 | #ifdef IPADDR_IN_DISPLAY | ||
1167 | /* | ||
1168 | * HPUX detects the local hostname in the DISPLAY variable and tries | ||
1169 | * to set up a shared memory connection to the server, which it | ||
1170 | * incorrectly supposes to be local. | ||
1171 | * | ||
1172 | * The workaround - as used in later $$H and other programs - is | ||
1173 | * is to set display to the host's IP address. | ||
1174 | */ | ||
1175 | { | ||
1176 | struct hostent *he; | ||
1177 | struct in_addr my_addr; | ||
1178 | |||
1179 | he = gethostbyname(hostname); | ||
1180 | if (he == NULL) { | ||
1181 | error("[X11-broken-fwd-hostname-workaround] Could not get " | ||
1182 | "IP address for hostname %s.", hostname); | ||
1183 | |||
1184 | packet_send_debug("[X11-broken-fwd-hostname-workaround]" | ||
1185 | "Could not get IP address for hostname %s.", hostname); | ||
1186 | |||
1187 | shutdown(sock, SHUT_RDWR); | ||
1188 | close(sock); | ||
1189 | |||
1190 | return NULL; | ||
1191 | } | ||
1192 | |||
1193 | memcpy(&my_addr, he->h_addr_list[0], sizeof(struct in_addr)); | ||
1194 | |||
1195 | /* Set DISPLAY to <ip address>:screen.display */ | ||
1196 | snprintf(buf, sizeof(buf), "%.50s:%d.%d", inet_ntoa(my_addr), | ||
1197 | display_number, screen_number); | ||
1198 | } | ||
1199 | #else /* IPADDR_IN_DISPLAY */ | ||
1200 | /* Just set DISPLAY to hostname:screen.display */ | ||
1164 | snprintf(buf, sizeof buf, "%.400s:%d.%d", hostname, | 1201 | snprintf(buf, sizeof buf, "%.400s:%d.%d", hostname, |
1165 | display_number, screen_number); | 1202 | display_number, screen_number); |
1203 | #endif /* IPADDR_IN_DISPLAY */ | ||
1166 | 1204 | ||
1167 | /* Allocate a channel for the socket. */ | 1205 | /* Allocate a channel for the socket. */ |
1168 | (void) channel_allocate(SSH_CHANNEL_X11_LISTENER, sock, | 1206 | (void) channel_allocate(SSH_CHANNEL_X11_LISTENER, sock, |