summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2010-07-16 13:56:43 +1000
committerDamien Miller <djm@mindrot.org>2010-07-16 13:56:43 +1000
commitd0244d498ba970b9d9348429eaf7a4a0ef2b903c (patch)
treeeab9c2d781ef6828fe5cac0f256cf24bff5962b8 /ssh.c
parent1f25ab43f4b374f920120b93ae3ed2f8521472c5 (diff)
- djm@cvs.openbsd.org 2010/07/12 22:41:13
[ssh.c ssh_config.5] expand %h to the hostname in ssh_config Hostname options. While this sounds useless, it is actually handy for working with unqualified hostnames: Host *.* Hostname %h Host * Hostname %h.example.org "I like it" markus@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ssh.c b/ssh.c
index e6073af7b..61fe10df0 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.342 2010/07/12 22:38:52 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.343 2010/07/12 22:41:13 djm 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
@@ -679,6 +679,11 @@ main(int ac, char **av)
679 options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT; 679 options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
680 } 680 }
681 681
682 if (options.hostname != NULL) {
683 host = percent_expand(options.hostname,
684 "h", host, (char *)NULL);
685 }
686
682 if (options.local_command != NULL) { 687 if (options.local_command != NULL) {
683 char thishost[NI_MAXHOST]; 688 char thishost[NI_MAXHOST];
684 689
@@ -688,16 +693,12 @@ main(int ac, char **av)
688 debug3("expanding LocalCommand: %s", options.local_command); 693 debug3("expanding LocalCommand: %s", options.local_command);
689 cp = options.local_command; 694 cp = options.local_command;
690 options.local_command = percent_expand(cp, "d", pw->pw_dir, 695 options.local_command = percent_expand(cp, "d", pw->pw_dir,
691 "h", options.hostname? options.hostname : host, 696 "h", host, "l", thishost, "n", host, "r", options.user,
692 "l", thishost, "n", host, "r", options.user, "p", buf, 697 "p", buf, "u", pw->pw_name, (char *)NULL);
693 "u", pw->pw_name, (char *)NULL);
694 debug3("expanded LocalCommand: %s", options.local_command); 698 debug3("expanded LocalCommand: %s", options.local_command);
695 xfree(cp); 699 xfree(cp);
696 } 700 }
697 701
698 if (options.hostname != NULL)
699 host = options.hostname;
700
701 /* force lowercase for hostkey matching */ 702 /* force lowercase for hostkey matching */
702 if (options.host_key_alias != NULL) { 703 if (options.host_key_alias != NULL) {
703 for (p = options.host_key_alias; *p; p++) 704 for (p = options.host_key_alias; *p; p++)