diff options
author | Damien Miller <djm@mindrot.org> | 2011-05-15 08:44:02 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2011-05-15 08:44:02 +1000 |
commit | dfc85fa1815004bd885473068e7578be3dcbdfef (patch) | |
tree | 639d29718bd5fd5f05bc8cbf9c273007f102554f | |
parent | d2ac5d74b4dd51d8e28615ea7af1ab5372a3db2b (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@
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ssh.c | 28 | ||||
-rw-r--r-- | ssh_config.5 | 17 |
3 files changed, 30 insertions, 19 deletions
@@ -19,6 +19,10 @@ | |||
19 | set traffic class for IPv6 traffic as we do for IPv4 TOS; | 19 | set traffic class for IPv6 traffic as we do for IPv4 TOS; |
20 | patch from lionel AT mamane.lu via Colin Watson in bz#1855; | 20 | patch from lionel AT mamane.lu via Colin Watson in bz#1855; |
21 | ok markus@ | 21 | ok markus@ |
22 | - djm@cvs.openbsd.org 2011/05/06 21:18:02 | ||
23 | [ssh.c ssh_config.5] | ||
24 | add a %L expansion (short-form of the local host name) for ControlPath; | ||
25 | sync some more expansions with LocalCommand; ok markus@ | ||
22 | 26 | ||
23 | 20110510 | 27 | 20110510 |
24 | - (dtucker) [openbsd-compat/openssl-compat.{c,h}] Bug #1882: fix | 28 | - (dtucker) [openbsd-compat/openssl-compat.{c,h}] Bug #1882: fix |
@@ -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) |
diff --git a/ssh_config.5 b/ssh_config.5 index 50bcae82f..a5bad8cc7 100644 --- a/ssh_config.5 +++ b/ssh_config.5 | |||
@@ -33,8 +33,8 @@ | |||
33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 33 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 34 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | .\" | 35 | .\" |
36 | .\" $OpenBSD: ssh_config.5,v 1.146 2010/12/08 04:02:47 djm Exp $ | 36 | .\" $OpenBSD: ssh_config.5,v 1.147 2011/05/06 21:18:02 djm Exp $ |
37 | .Dd $Mdocdate: December 8 2010 $ | 37 | .Dd $Mdocdate: May 6 2011 $ |
38 | .Dt SSH_CONFIG 5 | 38 | .Dt SSH_CONFIG 5 |
39 | .Os | 39 | .Os |
40 | .Sh NAME | 40 | .Sh NAME |
@@ -305,14 +305,21 @@ section above or the string | |||
305 | .Dq none | 305 | .Dq none |
306 | to disable connection sharing. | 306 | to disable connection sharing. |
307 | In the path, | 307 | In the path, |
308 | .Ql %L | ||
309 | will be substituted by the first component of the local host name, | ||
308 | .Ql %l | 310 | .Ql %l |
309 | will be substituted by the local host name, | 311 | will be substituted by the local host name (including any domain name), |
310 | .Ql %h | 312 | .Ql %h |
311 | will be substituted by the target host name, | 313 | will be substituted by the target host name, |
314 | .Ql %h | ||
315 | will be substituted by original target host name specified on the commandline, | ||
312 | .Ql %p | 316 | .Ql %p |
313 | the port, and | 317 | the port, |
314 | .Ql %r | 318 | .Ql %r |
315 | by the remote login username. | 319 | by the remote login username, and |
320 | .Ql %u | ||
321 | by the username of the user running | ||
322 | .Xr ssh 1 . | ||
316 | It is recommended that any | 323 | It is recommended that any |
317 | .Cm ControlPath | 324 | .Cm ControlPath |
318 | used for opportunistic connection sharing include | 325 | used for opportunistic connection sharing include |