upstream commit

reverse the order in which -J/JumpHost proxies are visited to
be more intuitive and document

reported by and manpage bits naddy@

Upstream-ID: 3a68fd6a841fd6cf8cedf6552a9607ba99df179a
This commit is contained in:
djm@openbsd.org 2016-07-22 03:35:11 +00:00 committed by Damien Miller
parent fcd135c9df
commit 286f5a77c3
2 changed files with 20 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: readconf.c,v 1.258 2016/07/20 10:45:27 naddy Exp $ */ /* $OpenBSD: readconf.c,v 1.259 2016/07/22 03:35:11 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -2292,7 +2292,12 @@ parse_jump(const char *s, Options *o, int active)
orig = sdup = xstrdup(s); orig = sdup = xstrdup(s);
first = active; first = active;
while ((cp = strsep(&sdup, ",")) && cp != NULL) { do {
if ((cp = strrchr(sdup, ',')) == NULL)
cp = sdup; /* last */
else
*cp++ = '\0';
if (first) { if (first) {
/* First argument and configuration is active */ /* First argument and configuration is active */
if (parse_user_host_port(cp, &user, &host, &port) != 0) if (parse_user_host_port(cp, &user, &host, &port) != 0)
@ -2303,7 +2308,7 @@ parse_jump(const char *s, Options *o, int active)
goto out; goto out;
} }
first = 0; /* only check syntax for subsequent hosts */ first = 0; /* only check syntax for subsequent hosts */
} } while (cp != sdup);
/* success */ /* success */
if (active) { if (active) {
o->jump_user = user; o->jump_user = user;
@ -2311,8 +2316,10 @@ parse_jump(const char *s, Options *o, int active)
o->jump_port = port; o->jump_port = port;
o->proxy_command = xstrdup("none"); o->proxy_command = xstrdup("none");
user = host = NULL; user = host = NULL;
if ((cp = strchr(s, ',')) != NULL && cp[1] != '\0') if ((cp = strrchr(s, ',')) != NULL && cp != s) {
o->jump_extra = xstrdup(cp + 1); o->jump_extra = xstrdup(s);
o->jump_extra[cp - s] = '\0';
}
} }
ret = 0; ret = 0;
out: out:
@ -2636,6 +2643,9 @@ dump_client_config(Options *o, const char *host)
strspn(o->jump_host, "1234567890.") == strlen(o->jump_host); strspn(o->jump_host, "1234567890.") == strlen(o->jump_host);
snprintf(buf, sizeof(buf), "%d", o->jump_port); snprintf(buf, sizeof(buf), "%d", o->jump_port);
printf("proxyjump %s%s%s%s%s%s%s%s%s\n", printf("proxyjump %s%s%s%s%s%s%s%s%s\n",
/* optional additional jump spec */
o->jump_extra == NULL ? "" : o->jump_extra,
o->jump_extra == NULL ? "" : ",",
/* optional user */ /* optional user */
o->jump_user == NULL ? "" : o->jump_user, o->jump_user == NULL ? "" : o->jump_user,
o->jump_user == NULL ? "" : "@", o->jump_user == NULL ? "" : "@",
@ -2647,9 +2657,6 @@ dump_client_config(Options *o, const char *host)
i ? "]" : "", i ? "]" : "",
/* optional port number */ /* optional port number */
o->jump_port <= 0 ? "" : ":", o->jump_port <= 0 ? "" : ":",
o->jump_port <= 0 ? "" : buf, o->jump_port <= 0 ? "" : buf);
/* optional additional jump spec */
o->jump_extra == NULL ? "" : ",",
o->jump_extra == NULL ? "" : o->jump_extra);
} }
} }

View File

@ -33,8 +33,8 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: ssh_config.5,v 1.234 2016/07/16 06:57:55 jmc Exp $ .\" $OpenBSD: ssh_config.5,v 1.235 2016/07/22 03:35:11 djm Exp $
.Dd $Mdocdate: July 16 2016 $ .Dd $Mdocdate: July 22 2016 $
.Dt SSH_CONFIG 5 .Dt SSH_CONFIG 5
.Os .Os
.Sh NAME .Sh NAME
@ -1367,7 +1367,8 @@ Specifies one or more jump proxies as
.Op : Ns Ar port .Op : Ns Ar port
.Sm on .Sm on
.Xc . .Xc .
Multiple proxies may be separated by comma characters. Multiple proxies may be separated by comma characters and will be visited
left-to-right.
Setting this option will cause Setting this option will cause
.Xr ssh 1 .Xr ssh 1
to connect to the target host by first making a to connect to the target host by first making a