]> andersk Git - openssh.git/commitdiff
- dtucker@cvs.openbsd.org 2008/06/12 16:35:31
authordtucker <dtucker>
Thu, 12 Jun 2008 18:56:37 +0000 (18:56 +0000)
committerdtucker <dtucker>
Thu, 12 Jun 2008 18:56:37 +0000 (18:56 +0000)
     [ssh_config.5 ssh.c]
     keyword expansion for localcommand.  ok djm@

ChangeLog
ssh.c
ssh_config.5

index d4d4197013d3013d0ab3b08925f4d54ebb96e76e..f4c9426dc9350cf35217e9694eba62998ba4fb1e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [clientloop.h channels.h clientloop.c channels.c mux.c]
      The multiplexing escape char handler commit last night introduced a
      small memory leak per session; plug it.
+   - dtucker@cvs.openbsd.org 2008/06/12 16:35:31
+     [ssh_config.5 ssh.c]
+     keyword expansion for localcommand.  ok djm@
 
 20080611
  - (djm) [channels.c configure.ac]
diff --git a/ssh.c b/ssh.c
index 96bfed9d50a94d6f2170d7fed8bd7fef4bc44e82..c15a1e4839da642d9f7c97b08ab29eb5993f17c7 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.316 2008/06/12 04:24:06 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.317 2008/06/12 16:35:31 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -647,6 +647,28 @@ main(int ac, char **av)
        if (options.user == NULL)
                options.user = xstrdup(pw->pw_name);
 
+       /* 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;
+       }
+
+       if (options.local_command != NULL) {
+               char thishost[NI_MAXHOST];
+
+               if (gethostname(thishost, sizeof(thishost)) == -1)
+                       fatal("gethostname: %s", strerror(errno));
+               snprintf(buf, sizeof(buf), "%d", options.port);
+               debug3("expanding LocalCommand: %s", options.local_command);
+               cp = options.local_command;
+               options.local_command = percent_expand(cp, "d", pw->pw_dir,
+                   "h", options.hostname? options.hostname : host,
+                    "l", thishost, "n", host, "r", options.user, "p", buf,
+                    "u", pw->pw_name, (char *)NULL);
+               debug3("expanded LocalCommand: %s", options.local_command);
+               xfree(cp);
+       }
+
        if (options.hostname != NULL)
                host = options.hostname;
 
@@ -657,12 +679,6 @@ main(int ac, char **av)
                                *p = (char)tolower(*p);
        }
 
-       /* 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;
-       }
-
        if (options.proxy_command != NULL &&
            strcmp(options.proxy_command, "none") == 0) {
                xfree(options.proxy_command);
index 8f40a14cb26a9b47678057ea462ea5b0aceed042..4f4678d5b31d1021085f10e1d66bd73e06b0f874 100644 (file)
@@ -34,7 +34,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $OpenBSD: ssh_config.5,v 1.108 2008/06/11 23:03:56 grunk Exp $
+.\" $OpenBSD: ssh_config.5,v 1.109 2008/06/12 16:35:31 dtucker Exp $
 .Dd $Mdocdate$
 .Dt SSH_CONFIG 5
 .Os
@@ -606,6 +606,21 @@ Specifies a command to execute on the local machine after successfully
 connecting to the server.
 The command string extends to the end of the line, and is executed with
 the user's shell.
+The following escape character substitutions will be performed:
+.Ql %d
+(local user's home directory),
+.Ql %h
+(remote host name),
+.Ql %l
+(local host name),
+.Ql %n
+(host name as provided on the command line),
+.Ql %p
+(remote port),
+.Ql %r
+(remote user name) or
+.Ql %u
+(local user name).
 This directive is ignored unless
 .Cm PermitLocalCommand
 has been enabled.
This page took 0.039089 seconds and 5 git commands to generate.