diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2005-06-17 22:53:48 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2005-06-17 22:53:48 +0000 |
commit | 62422f756a398f490310170a6e3e3b454216f45c (patch) | |
tree | c1f0f9107368090b66d377de895ef92588bab3b9 /usr.bin | |
parent | aa63bd8662fe09c801819e31bcb985a531c0d138 (diff) |
Fix ControlPath's %p expanding to "0" for a default port,
spotted dwmw2 AT infradead.org; ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/ssh.c | 9 | ||||
-rw-r--r-- | usr.bin/ssh/sshconnect.c | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c index 4c34123f2de..813406f8e71 100644 --- a/usr.bin/ssh/ssh.c +++ b/usr.bin/ssh/ssh.c @@ -40,7 +40,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh.c,v 1.243 2005/06/16 03:38:36 djm Exp $"); +RCSID("$OpenBSD: ssh.c,v 1.244 2005/06/17 22:53:46 djm Exp $"); #include <openssl/evp.h> #include <openssl/err.h> @@ -185,6 +185,7 @@ main(int ac, char **av) int dummy; extern int optind, optreset; extern char *optarg; + struct servent *sp; Forward fwd; /* @@ -616,6 +617,12 @@ again: if (options.control_path != NULL) control_client(options.control_path); + /* Get default port if port has not been set. */ + if (options.port == 0) { + sp = getservbyname(SSH_SERVICE_NAME, "tcp"); + options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; + } + /* Open a connection to the remote host. */ if (ssh_connect(host, &hostaddr, options.port, options.address_family, options.connection_attempts, diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c index fac55224bd5..e0ac679086c 100644 --- a/usr.bin/ssh/sshconnect.c +++ b/usr.bin/ssh/sshconnect.c @@ -13,7 +13,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect.c,v 1.165 2005/06/17 02:44:33 djm Exp $"); +RCSID("$OpenBSD: sshconnect.c,v 1.166 2005/06/17 22:53:47 djm Exp $"); #include <openssl/bn.h> @@ -285,18 +285,9 @@ 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 servent *sp; debug2("ssh_connect: needpriv %d", needpriv); - /* Get default port if port has not been set. */ - if (port == 0) { - sp = getservbyname(SSH_SERVICE_NAME, "tcp"); - if (sp) - port = ntohs(sp->s_port); - else - port = SSH_DEFAULT_PORT; - } /* If a proxy command is given, connect using it. */ if (proxy_command != NULL) return ssh_proxy_connect(host, port, proxy_command); |