[channels.c sshconnect.c sshd.c]
     remove use of SO_LINGER, it should not be needed. error check
     SO_REUSEADDR. fixup comments. ok markus@
This commit is contained in:
Damien Miller 2002-09-19 11:49:37 +10:00
parent f37e246f85
commit e1383cee9d
4 changed files with 19 additions and 42 deletions

View File

@ -6,6 +6,10 @@
- stevesk@cvs.openbsd.org 2002/09/12 19:50:36 - stevesk@cvs.openbsd.org 2002/09/12 19:50:36
[session.c ssh.1] [session.c ssh.1]
add SSH_CONNECTION and deprecate SSH_CLIENT; bug #384. ok markus@ 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 20020912
- (djm) Made GNOME askpass programs return non-zero if cancel button is - (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; save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@ 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 $

View File

@ -39,7 +39,7 @@
*/ */
#include "includes.h" #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 "ssh.h"
#include "ssh1.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; struct addrinfo hints, *ai, *aitop;
const char *host; const char *host;
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; char ntop[NI_MAXHOST], strport[NI_MAXSERV];
struct linger linger;
success = 0; success = 0;
host = (type == SSH_CHANNEL_RPORT_LISTENER) ? 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; continue;
} }
/* /*
* Set socket options. We would like the socket to disappear * Set socket options.
* as soon as it has been closed for whatever reason. * Allow local port reuse in TIME_WAIT.
*/ */
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on,
linger.l_onoff = 1; sizeof(on)) == -1)
linger.l_linger = 5; error("setsockopt SO_REUSEADDR: %s", strerror(errno));
setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger));
debug("Local forwarding listening on %s port %s.", ntop, strport); debug("Local forwarding listening on %s port %s.", ntop, strport);
/* Bind the socket to the address. */ /* Bind the socket to the address. */

View File

@ -13,7 +13,7 @@
*/ */
#include "includes.h" #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> #include <openssl/bn.h>
@ -229,7 +229,6 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
int sock = -1, attempt; int sock = -1, attempt;
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; char ntop[NI_MAXHOST], strport[NI_MAXSERV];
struct addrinfo hints, *ai, *aitop; struct addrinfo hints, *ai, *aitop;
struct linger linger;
struct servent *sp; struct servent *sp;
/* /*
* Did we get only other errors than "Connection refused" (which * 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."); 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. */ /* Set keepalives if requested. */
if (options.keepalives && if (options.keepalives &&
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,

28
sshd.c
View File

@ -42,7 +42,7 @@
*/ */
#include "includes.h" #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/dh.h>
#include <openssl/bn.h> #include <openssl/bn.h>
@ -806,7 +806,6 @@ main(int ac, char **av)
const char *remote_ip; const char *remote_ip;
int remote_port; int remote_port;
FILE *f; FILE *f;
struct linger linger;
struct addrinfo *ai; struct addrinfo *ai;
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; char ntop[NI_MAXHOST], strport[NI_MAXSERV];
int listen_sock, maxfd; int listen_sock, maxfd;
@ -1152,17 +1151,12 @@ main(int ac, char **av)
continue; continue;
} }
/* /*
* Set socket options. We try to make the port * Set socket options.
* reusable and have it close as fast as possible * Allow local port reuse in TIME_WAIT.
* without waiting in unnecessary wait states on
* close.
*/ */
setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, if (setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR,
&on, sizeof(on)); &on, sizeof(on)) == -1)
linger.l_onoff = 1; error("setsockopt SO_REUSEADDR: %s", strerror(errno));
linger.l_linger = 5;
setsockopt(listen_sock, SOL_SOCKET, SO_LINGER,
&linger, sizeof(linger));
debug("Bind to port %s on %s.", strport, ntop); debug("Bind to port %s on %s.", strport, ntop);
@ -1411,16 +1405,6 @@ main(int ac, char **av)
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
signal(SIGINT, 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. */ /* Set keepalives if requested. */
if (options.keepalives && if (options.keepalives &&
setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on, setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on,