summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--channels.c15
-rw-r--r--sshconnect.c12
-rw-r--r--sshd.c28
4 files changed, 19 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index 43c701af..b0b40b28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@
- stevesk@cvs.openbsd.org 2002/09/12 19:50:36
[session.c ssh.1]
add SSH_CONNECTION and deprecate SSH_CLIENT; bug #384. ok markus@
+ - stevesk@cvs.openbsd.org 2002/09/13 19:23:09
+ [channels.c sshconnect.c sshd.c]
+ remove use of SO_LINGER, it should not be needed. error check
+ SO_REUSEADDR. fixup comments. ok markus@
20020912
- (djm) Made GNOME askpass programs return non-zero if cancel button is
@@ -656,4 +660,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@
-$Id: ChangeLog,v 1.2465 2002/09/19 01:47:55 djm Exp $
+$Id: ChangeLog,v 1.2466 2002/09/19 01:49:37 djm Exp $
diff --git a/channels.c b/channels.c
index 0ae37b6d..cf1a6462 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.181 2002/09/09 14:54:14 markus Exp $");
+RCSID("$OpenBSD: channels.c,v 1.182 2002/09/13 19:23:09 stevesk Exp $");
#include "ssh.h"
#include "ssh1.h"
@@ -2022,7 +2022,6 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por
struct addrinfo hints, *ai, *aitop;
const char *host;
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
- struct linger linger;
success = 0;
host = (type == SSH_CHANNEL_RPORT_LISTENER) ?
@@ -2065,13 +2064,13 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por
continue;
}
/*
- * Set socket options. We would like the socket to disappear
- * as soon as it has been closed for whatever reason.
+ * Set socket options.
+ * Allow local port reuse in TIME_WAIT.
*/
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
- linger.l_onoff = 1;
- linger.l_linger = 5;
- setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger));
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on,
+ sizeof(on)) == -1)
+ error("setsockopt SO_REUSEADDR: %s", strerror(errno));
+
debug("Local forwarding listening on %s port %s.", ntop, strport);
/* Bind the socket to the address. */
diff --git a/sshconnect.c b/sshconnect.c
index 6004bf5e..0cb82485 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.133 2002/07/29 18:57:30 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.134 2002/09/13 19:23:09 stevesk Exp $");
#include <openssl/bn.h>
@@ -229,7 +229,6 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
int sock = -1, attempt;
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
struct addrinfo hints, *ai, *aitop;
- struct linger linger;
struct servent *sp;
/*
* Did we get only other errors than "Connection refused" (which
@@ -330,15 +329,6 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
debug("Connection established.");
- /*
- * Set socket options. We would like the socket to disappear as soon
- * as it has been closed for whatever reason.
- */
- /* setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); */
- linger.l_onoff = 1;
- linger.l_linger = 5;
- setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&linger, sizeof(linger));
-
/* Set keepalives if requested. */
if (options.keepalives &&
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,
diff --git a/sshd.c b/sshd.c
index 55c57e19..17f00166 100644
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.257 2002/07/23 16:03:10 stevesk Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.258 2002/09/13 19:23:09 stevesk Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -806,7 +806,6 @@ main(int ac, char **av)
const char *remote_ip;
int remote_port;
FILE *f;
- struct linger linger;
struct addrinfo *ai;
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
int listen_sock, maxfd;
@@ -1152,17 +1151,12 @@ main(int ac, char **av)
continue;
}
/*
- * Set socket options. We try to make the port
- * reusable and have it close as fast as possible
- * without waiting in unnecessary wait states on
- * close.
+ * Set socket options.
+ * Allow local port reuse in TIME_WAIT.
*/
- setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
- &on, sizeof(on));
- linger.l_onoff = 1;
- linger.l_linger = 5;
- setsockopt(listen_sock, SOL_SOCKET, SO_LINGER,
- &linger, sizeof(linger));
+ if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
+ &on, sizeof(on)) == -1)
+ error("setsockopt SO_REUSEADDR: %s", strerror(errno));
debug("Bind to port %s on %s.", strport, ntop);
@@ -1411,16 +1405,6 @@ main(int ac, char **av)
signal(SIGCHLD, SIG_DFL);
signal(SIGINT, SIG_DFL);
- /*
- * Set socket options for the connection. We want the socket to
- * close as fast as possible without waiting for anything. If the
- * connection is not a socket, these will do nothing.
- */
- /* setsockopt(sock_in, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)); */
- linger.l_onoff = 1;
- linger.l_linger = 5;
- setsockopt(sock_in, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger));
-
/* Set keepalives if requested. */
if (options.keepalives &&
setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on,