summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ssh.c30
-rw-r--r--ssh_config.519
3 files changed, 44 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 0aec356d3..cbf5a0851 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -112,6 +112,9 @@
112 [clientloop.h channels.h clientloop.c channels.c mux.c] 112 [clientloop.h channels.h clientloop.c channels.c mux.c]
113 The multiplexing escape char handler commit last night introduced a 113 The multiplexing escape char handler commit last night introduced a
114 small memory leak per session; plug it. 114 small memory leak per session; plug it.
115 - dtucker@cvs.openbsd.org 2008/06/12 16:35:31
116 [ssh_config.5 ssh.c]
117 keyword expansion for localcommand. ok djm@
115 118
11620080611 11920080611
117 - (djm) [channels.c configure.ac] 120 - (djm) [channels.c configure.ac]
@@ -4274,4 +4277,4 @@
4274 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4277 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4275 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4278 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4276 4279
4277$Id: ChangeLog,v 1.4984 2008/06/12 18:55:46 dtucker Exp $ 4280$Id: ChangeLog,v 1.4985 2008/06/12 18:56:37 dtucker Exp $
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);
diff --git a/ssh_config.5 b/ssh_config.5
index 8bcf323cc..98cd9ac5b 100644
--- a/ssh_config.5
+++ b/ssh_config.5
@@ -34,8 +34,8 @@
34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36.\" 36.\"
37.\" $OpenBSD: ssh_config.5,v 1.108 2008/06/11 23:03:56 grunk Exp $ 37.\" $OpenBSD: ssh_config.5,v 1.109 2008/06/12 16:35:31 dtucker Exp $
38.Dd $Mdocdate: June 11 2008 $ 38.Dd $Mdocdate: June 12 2008 $
39.Dt SSH_CONFIG 5 39.Dt SSH_CONFIG 5
40.Os 40.Os
41.Sh NAME 41.Sh NAME
@@ -606,6 +606,21 @@ Specifies a command to execute on the local machine after successfully
606connecting to the server. 606connecting to the server.
607The command string extends to the end of the line, and is executed with 607The command string extends to the end of the line, and is executed with
608the user's shell. 608the user's shell.
609The following escape character substitutions will be performed:
610.Ql %d
611(local user's home directory),
612.Ql %h
613(remote host name),
614.Ql %l
615(local host name),
616.Ql %n
617(host name as provided on the command line),
618.Ql %p
619(remote port),
620.Ql %r
621(remote user name) or
622.Ql %u
623(local user name).
609This directive is ignored unless 624This directive is ignored unless
610.Cm PermitLocalCommand 625.Cm PermitLocalCommand
611has been enabled. 626has been enabled.