summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-13 04:56:37 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-13 04:56:37 +1000
commitf6b01b758f4003a5cc59cf6a27afdc5123eb4fc4 (patch)
tree05a150e5907561fe53063cfef329007811d52756 /ssh.c
parent84c56f536ca664f79172d595e088fce6aa84be21 (diff)
- dtucker@cvs.openbsd.org 2008/06/12 16:35:31
[ssh_config.5 ssh.c] keyword expansion for localcommand. ok djm@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/ssh.c b/ssh.c
index 96bfed9d5..c15a1e483 100644
--- a/ssh.c
+++ b/ssh.c
@@ -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);