summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-05-15 08:44:02 +1000
committerDamien Miller <djm@mindrot.org>2011-05-15 08:44:02 +1000
commitdfc85fa1815004bd885473068e7578be3dcbdfef (patch)
tree639d29718bd5fd5f05bc8cbf9c273007f102554f /ssh.c
parentd2ac5d74b4dd51d8e28615ea7af1ab5372a3db2b (diff)
- djm@cvs.openbsd.org 2011/05/06 21:18:02
[ssh.c ssh_config.5] add a %L expansion (short-form of the local host name) for ControlPath; sync some more expansions with LocalCommand; ok markus@
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/ssh.c b/ssh.c
index 4fd131c20..549dd5c22 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.c,v 1.357 2011/04/17 22:42:42 djm Exp $ */ 1/* $OpenBSD: ssh.c,v 1.358 2011/05/06 21:18:02 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
@@ -222,6 +222,7 @@ main(int ac, char **av)
222{ 222{
223 int i, r, opt, exit_status, use_syslog; 223 int i, r, opt, exit_status, use_syslog;
224 char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg; 224 char *p, *cp, *line, *argv0, buf[MAXPATHLEN], *host_arg;
225 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
225 struct stat st; 226 struct stat st;
226 struct passwd *pw; 227 struct passwd *pw;
227 int dummy, timeout_ms; 228 int dummy, timeout_ms;
@@ -701,17 +702,19 @@ main(int ac, char **av)
701 "h", host, (char *)NULL); 702 "h", host, (char *)NULL);
702 } 703 }
703 704
704 if (options.local_command != NULL) { 705 if (gethostname(thishost, sizeof(thishost)) == -1)
705 char thishost[NI_MAXHOST]; 706 fatal("gethostname: %s", strerror(errno));
707 strlcpy(shorthost, thishost, sizeof(shorthost));
708 shorthost[strcspn(thishost, ".")] = '\0';
709 snprintf(portstr, sizeof(portstr), "%d", options.port);
706 710
707 if (gethostname(thishost, sizeof(thishost)) == -1) 711 if (options.local_command != NULL) {
708 fatal("gethostname: %s", strerror(errno));
709 snprintf(buf, sizeof(buf), "%d", options.port);
710 debug3("expanding LocalCommand: %s", options.local_command); 712 debug3("expanding LocalCommand: %s", options.local_command);
711 cp = options.local_command; 713 cp = options.local_command;
712 options.local_command = percent_expand(cp, "d", pw->pw_dir, 714 options.local_command = percent_expand(cp, "d", pw->pw_dir,
713 "h", host, "l", thishost, "n", host_arg, "r", options.user, 715 "h", host, "l", thishost, "n", host_arg, "r", options.user,
714 "p", buf, "u", pw->pw_name, (char *)NULL); 716 "p", portstr, "u", pw->pw_name, "L", shorthost,
717 (char *)NULL);
715 debug3("expanded LocalCommand: %s", options.local_command); 718 debug3("expanded LocalCommand: %s", options.local_command);
716 xfree(cp); 719 xfree(cp);
717 } 720 }
@@ -735,16 +738,13 @@ main(int ac, char **av)
735 } 738 }
736 739
737 if (options.control_path != NULL) { 740 if (options.control_path != NULL) {
738 char thishost[NI_MAXHOST];
739
740 if (gethostname(thishost, sizeof(thishost)) == -1)
741 fatal("gethostname: %s", strerror(errno));
742 snprintf(buf, sizeof(buf), "%d", options.port);
743 cp = tilde_expand_filename(options.control_path, 741 cp = tilde_expand_filename(options.control_path,
744 original_real_uid); 742 original_real_uid);
745 xfree(options.control_path); 743 xfree(options.control_path);
746 options.control_path = percent_expand(cp, "p", buf, "h", host, 744 options.control_path = percent_expand(cp, "h", host,
747 "r", options.user, "l", thishost, (char *)NULL); 745 "l", thishost, "n", host_arg, "r", options.user,
746 "p", portstr, "u", pw->pw_name, "L", shorthost,
747 (char *)NULL);
748 xfree(cp); 748 xfree(cp);
749 } 749 }
750 if (muxclient_command != 0 && options.control_path == NULL) 750 if (muxclient_command != 0 && options.control_path == NULL)