diff --git a/ChangeLog b/ChangeLog index 04dce8489..c60eacc11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +20050626 + - (djm) OpenBSD CVS Sync + - djm@cvs.openbsd.org 2005/06/17 22:53:47 + [ssh.c sshconnect.c] + Fix ControlPath's %p expanding to "0" for a default port, + spotted dwmw2 AT infradead.org; ok markus@ + 20050618 - (djm) OpenBSD CVS Sync - djm@cvs.openbsd.org 2005/05/20 12:57:01; @@ -2749,4 +2756,4 @@ - (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu -$Id: ChangeLog,v 1.3827 2005/06/19 00:19:43 djm Exp $ +$Id: ChangeLog,v 1.3828 2005/06/25 22:55:25 djm Exp $ diff --git a/ssh.c b/ssh.c index 5d53cd680..2e93b161a 100644 --- a/ssh.c +++ b/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 #include @@ -185,6 +185,7 @@ main(int ac, char **av) int dummy; extern int optind, optreset; extern char *optarg; + struct servent *sp; Forward fwd; __progname = ssh_get_progname(av[0]); @@ -623,6 +624,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/sshconnect.c b/sshconnect.c index cbbe54821..92f0f3800 100644 --- a/sshconnect.c +++ b/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 @@ -289,18 +289,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);