diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.316 2008/06/12 04:24:06 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.317 2008/06/12 16:35:31 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -647,6 +647,28 @@ main(int ac, char **av) | |||
647 | if (options.user == NULL) | 647 | if (options.user == NULL) |
648 | options.user = xstrdup(pw->pw_name); | 648 | options.user = xstrdup(pw->pw_name); |
649 | 649 | ||
650 | /* Get default port if port has not been set. */ | ||
651 | if (options.port == 0) { | ||
652 | sp = getservbyname(SSH_SERVICE_NAME, "tcp"); | ||
653 | options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; | ||
654 | } | ||
655 | |||
656 | if (options.local_command != NULL) { | ||
657 | char thishost[NI_MAXHOST]; | ||
658 | |||
659 | if (gethostname(thishost, sizeof(thishost)) == -1) | ||
660 | fatal("gethostname: %s", strerror(errno)); | ||
661 | snprintf(buf, sizeof(buf), "%d", options.port); | ||
662 | debug3("expanding LocalCommand: %s", options.local_command); | ||
663 | cp = options.local_command; | ||
664 | options.local_command = percent_expand(cp, "d", pw->pw_dir, | ||
665 | "h", options.hostname? options.hostname : host, | ||
666 | "l", thishost, "n", host, "r", options.user, "p", buf, | ||
667 | "u", pw->pw_name, (char *)NULL); | ||
668 | debug3("expanded LocalCommand: %s", options.local_command); | ||
669 | xfree(cp); | ||
670 | } | ||
671 | |||
650 | if (options.hostname != NULL) | 672 | if (options.hostname != NULL) |
651 | host = options.hostname; | 673 | host = options.hostname; |
652 | 674 | ||
@@ -657,12 +679,6 @@ main(int ac, char **av) | |||
657 | *p = (char)tolower(*p); | 679 | *p = (char)tolower(*p); |
658 | } | 680 | } |
659 | 681 | ||
660 | /* Get default port if port has not been set. */ | ||
661 | if (options.port == 0) { | ||
662 | sp = getservbyname(SSH_SERVICE_NAME, "tcp"); | ||
663 | options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; | ||
664 | } | ||
665 | |||
666 | if (options.proxy_command != NULL && | 682 | if (options.proxy_command != NULL && |
667 | strcmp(options.proxy_command, "none") == 0) { | 683 | strcmp(options.proxy_command, "none") == 0) { |
668 | xfree(options.proxy_command); | 684 | xfree(options.proxy_command); |