summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/readconf.c b/readconf.c
index 8b5b21907..c177202b1 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.258 2016/07/20 10:45:27 naddy Exp $ */ 1/* $OpenBSD: readconf.c,v 1.259 2016/07/22 03:35:11 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
@@ -2292,7 +2292,12 @@ parse_jump(const char *s, Options *o, int active)
2292 2292
2293 orig = sdup = xstrdup(s); 2293 orig = sdup = xstrdup(s);
2294 first = active; 2294 first = active;
2295 while ((cp = strsep(&sdup, ",")) && cp != NULL) { 2295 do {
2296 if ((cp = strrchr(sdup, ',')) == NULL)
2297 cp = sdup; /* last */
2298 else
2299 *cp++ = '\0';
2300
2296 if (first) { 2301 if (first) {
2297 /* First argument and configuration is active */ 2302 /* First argument and configuration is active */
2298 if (parse_user_host_port(cp, &user, &host, &port) != 0) 2303 if (parse_user_host_port(cp, &user, &host, &port) != 0)
@@ -2303,7 +2308,7 @@ parse_jump(const char *s, Options *o, int active)
2303 goto out; 2308 goto out;
2304 } 2309 }
2305 first = 0; /* only check syntax for subsequent hosts */ 2310 first = 0; /* only check syntax for subsequent hosts */
2306 } 2311 } while (cp != sdup);
2307 /* success */ 2312 /* success */
2308 if (active) { 2313 if (active) {
2309 o->jump_user = user; 2314 o->jump_user = user;
@@ -2311,8 +2316,10 @@ parse_jump(const char *s, Options *o, int active)
2311 o->jump_port = port; 2316 o->jump_port = port;
2312 o->proxy_command = xstrdup("none"); 2317 o->proxy_command = xstrdup("none");
2313 user = host = NULL; 2318 user = host = NULL;
2314 if ((cp = strchr(s, ',')) != NULL && cp[1] != '\0') 2319 if ((cp = strrchr(s, ',')) != NULL && cp != s) {
2315 o->jump_extra = xstrdup(cp + 1); 2320 o->jump_extra = xstrdup(s);
2321 o->jump_extra[cp - s] = '\0';
2322 }
2316 } 2323 }
2317 ret = 0; 2324 ret = 0;
2318 out: 2325 out:
@@ -2636,6 +2643,9 @@ dump_client_config(Options *o, const char *host)
2636 strspn(o->jump_host, "1234567890.") == strlen(o->jump_host); 2643 strspn(o->jump_host, "1234567890.") == strlen(o->jump_host);
2637 snprintf(buf, sizeof(buf), "%d", o->jump_port); 2644 snprintf(buf, sizeof(buf), "%d", o->jump_port);
2638 printf("proxyjump %s%s%s%s%s%s%s%s%s\n", 2645 printf("proxyjump %s%s%s%s%s%s%s%s%s\n",
2646 /* optional additional jump spec */
2647 o->jump_extra == NULL ? "" : o->jump_extra,
2648 o->jump_extra == NULL ? "" : ",",
2639 /* optional user */ 2649 /* optional user */
2640 o->jump_user == NULL ? "" : o->jump_user, 2650 o->jump_user == NULL ? "" : o->jump_user,
2641 o->jump_user == NULL ? "" : "@", 2651 o->jump_user == NULL ? "" : "@",
@@ -2647,9 +2657,6 @@ dump_client_config(Options *o, const char *host)
2647 i ? "]" : "", 2657 i ? "]" : "",
2648 /* optional port number */ 2658 /* optional port number */
2649 o->jump_port <= 0 ? "" : ":", 2659 o->jump_port <= 0 ? "" : ":",
2650 o->jump_port <= 0 ? "" : buf, 2660 o->jump_port <= 0 ? "" : buf);
2651 /* optional additional jump spec */
2652 o->jump_extra == NULL ? "" : ",",
2653 o->jump_extra == NULL ? "" : o->jump_extra);
2654 } 2661 }
2655} 2662}