diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | channels.c | 27 |
2 files changed, 24 insertions, 10 deletions
@@ -12,6 +12,11 @@ | |||
12 | fix regression I introduced in 4.2: X11 forwardings initiated after | 12 | fix regression I introduced in 4.2: X11 forwardings initiated after |
13 | a session has exited (e.g. "(sleep 5; xterm) &") would not start. | 13 | a session has exited (e.g. "(sleep 5; xterm) &") would not start. |
14 | bz #1086 reported by t8m AT centrum.cz; ok markus@ dtucker@ | 14 | bz #1086 reported by t8m AT centrum.cz; ok markus@ dtucker@ |
15 | - djm@cvs.openbsd.org 2005/10/11 23:37:37 | ||
16 | [channels.c] | ||
17 | bz #1076 set SO_REUSEADDR on X11 forwarding listner sockets, preventing | ||
18 | bind() failure when a previous connection's listeners are in TIME_WAIT, | ||
19 | reported by plattner AT inf.ethz.ch; ok dtucker@ | ||
15 | 20 | ||
16 | 20051102 | 21 | 20051102 |
17 | - (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup(). | 22 | - (dtucker) [openbsd-compat/bsd-misc.c] Bug #1108: fix broken strdup(). |
@@ -3145,4 +3150,4 @@ | |||
3145 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 3150 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
3146 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 3151 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
3147 | 3152 | ||
3148 | $Id: ChangeLog,v 1.3928 2005/11/05 03:52:50 djm Exp $ | 3153 | $Id: ChangeLog,v 1.3929 2005/11/05 03:53:39 djm Exp $ |
diff --git a/channels.c b/channels.c index b0bc77901..175b59e44 100644 --- a/channels.c +++ b/channels.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include "includes.h" | 41 | #include "includes.h" |
42 | RCSID("$OpenBSD: channels.c,v 1.225 2005/10/10 10:23:08 djm Exp $"); | 42 | RCSID("$OpenBSD: channels.c,v 1.226 2005/10/11 23:37:37 djm Exp $"); |
43 | 43 | ||
44 | #include "ssh.h" | 44 | #include "ssh.h" |
45 | #include "ssh1.h" | 45 | #include "ssh1.h" |
@@ -1230,6 +1230,19 @@ port_open_helper(Channel *c, char *rtype) | |||
1230 | xfree(remote_ipaddr); | 1230 | xfree(remote_ipaddr); |
1231 | } | 1231 | } |
1232 | 1232 | ||
1233 | static void | ||
1234 | channel_set_reuseaddr(int fd) | ||
1235 | { | ||
1236 | int on = 1; | ||
1237 | |||
1238 | /* | ||
1239 | * Set socket options. | ||
1240 | * Allow local port reuse in TIME_WAIT. | ||
1241 | */ | ||
1242 | if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) | ||
1243 | error("setsockopt SO_REUSEADDR fd %d: %s", fd, strerror(errno)); | ||
1244 | } | ||
1245 | |||
1233 | /* | 1246 | /* |
1234 | * This socket is listening for connections to a forwarded TCP/IP port. | 1247 | * This socket is listening for connections to a forwarded TCP/IP port. |
1235 | */ | 1248 | */ |
@@ -2191,7 +2204,7 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por | |||
2191 | const char *host_to_connect, u_short port_to_connect, int gateway_ports) | 2204 | const char *host_to_connect, u_short port_to_connect, int gateway_ports) |
2192 | { | 2205 | { |
2193 | Channel *c; | 2206 | Channel *c; |
2194 | int sock, r, success = 0, on = 1, wildcard = 0, is_client; | 2207 | int sock, r, success = 0, wildcard = 0, is_client; |
2195 | struct addrinfo hints, *ai, *aitop; | 2208 | struct addrinfo hints, *ai, *aitop; |
2196 | const char *host, *addr; | 2209 | const char *host, *addr; |
2197 | char ntop[NI_MAXHOST], strport[NI_MAXSERV]; | 2210 | char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
@@ -2278,13 +2291,8 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por | |||
2278 | verbose("socket: %.100s", strerror(errno)); | 2291 | verbose("socket: %.100s", strerror(errno)); |
2279 | continue; | 2292 | continue; |
2280 | } | 2293 | } |
2281 | /* | 2294 | |
2282 | * Set socket options. | 2295 | channel_set_reuseaddr(sock); |
2283 | * Allow local port reuse in TIME_WAIT. | ||
2284 | */ | ||
2285 | if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, | ||
2286 | sizeof(on)) == -1) | ||
2287 | error("setsockopt SO_REUSEADDR: %s", strerror(errno)); | ||
2288 | 2296 | ||
2289 | debug("Local forwarding listening on %s port %s.", ntop, strport); | 2297 | debug("Local forwarding listening on %s port %s.", ntop, strport); |
2290 | 2298 | ||
@@ -2710,6 +2718,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost, | |||
2710 | error("setsockopt IPV6_V6ONLY: %.100s", strerror(errno)); | 2718 | error("setsockopt IPV6_V6ONLY: %.100s", strerror(errno)); |
2711 | } | 2719 | } |
2712 | #endif | 2720 | #endif |
2721 | channel_set_reuseaddr(sock); | ||
2713 | if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { | 2722 | if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) { |
2714 | debug2("bind port %d: %.100s", port, strerror(errno)); | 2723 | debug2("bind port %d: %.100s", port, strerror(errno)); |
2715 | close(sock); | 2724 | close(sock); |