diff options
author | Damien Miller <djm@mindrot.org> | 2008-11-03 19:27:34 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-11-03 19:27:34 +1100 |
commit | a699d952e5e20be83fada0ff10ba8e02ad4dcd81 (patch) | |
tree | adf8a09fff19c76ae0e550fe7fe367c61914160d | |
parent | c1719f7f0d3f828ae5ca0ac339813a64169becef (diff) |
- stevesk@cvs.openbsd.org 2008/11/01 17:40:33
[clientloop.c readconf.c readconf.h ssh.c]
merge dynamic forward parsing into parse_forward(); 'i think this is OK' djm@
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | clientloop.c | 4 | ||||
-rw-r--r-- | readconf.c | 82 | ||||
-rw-r--r-- | readconf.h | 4 | ||||
-rw-r--r-- | ssh.c | 32 |
5 files changed, 62 insertions, 66 deletions
@@ -92,6 +92,10 @@ | |||
92 | - sobrado@cvs.openbsd.org 2008/11/01 11:14:36 | 92 | - sobrado@cvs.openbsd.org 2008/11/01 11:14:36 |
93 | [ssh-keyscan.1 ssh-keyscan.c] | 93 | [ssh-keyscan.1 ssh-keyscan.c] |
94 | the ellipsis is not an optional argument; while here, improve spacing. | 94 | the ellipsis is not an optional argument; while here, improve spacing. |
95 | - stevesk@cvs.openbsd.org 2008/11/01 17:40:33 | ||
96 | [clientloop.c readconf.c readconf.h ssh.c] | ||
97 | merge dynamic forward parsing into parse_forward(); | ||
98 | 'i think this is OK' djm@ | ||
95 | 99 | ||
96 | 20080906 | 100 | 20080906 |
97 | - (dtucker) [config.guess config.sub] Update to latest versions from | 101 | - (dtucker) [config.guess config.sub] Update to latest versions from |
@@ -4826,4 +4830,4 @@ | |||
4826 | OpenServer 6 and add osr5bigcrypt support so when someone migrates | 4830 | OpenServer 6 and add osr5bigcrypt support so when someone migrates |
4827 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ | 4831 | passwords between UnixWare and OpenServer they will still work. OK dtucker@ |
4828 | 4832 | ||
4829 | $Id: ChangeLog,v 1.5121 2008/11/03 08:27:07 djm Exp $ | 4833 | $Id: ChangeLog,v 1.5122 2008/11/03 08:27:34 djm Exp $ |
diff --git a/clientloop.c b/clientloop.c index 30e17d20c..0ed4194a6 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: clientloop.c,v 1.202 2008/10/30 19:31:16 stevesk Exp $ */ | 1 | /* $OpenBSD: clientloop.c,v 1.203 2008/11/01 17:40:33 stevesk 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 |
@@ -842,7 +842,7 @@ process_cmdline(void) | |||
842 | } | 842 | } |
843 | channel_request_rforward_cancel(cancel_host, cancel_port); | 843 | channel_request_rforward_cancel(cancel_host, cancel_port); |
844 | } else { | 844 | } else { |
845 | if (!parse_forward(&fwd, s)) { | 845 | if (!parse_forward(&fwd, s, 0)) { |
846 | logit("Bad forwarding specification."); | 846 | logit("Bad forwarding specification."); |
847 | goto out; | 847 | goto out; |
848 | } | 848 | } |
diff --git a/readconf.c b/readconf.c index 73f6eb361..27be8df68 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.167 2008/06/26 11:46:31 grunk Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.168 2008/11/01 17:40:33 stevesk 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 |
@@ -706,56 +706,39 @@ parse_int: | |||
706 | 706 | ||
707 | case oLocalForward: | 707 | case oLocalForward: |
708 | case oRemoteForward: | 708 | case oRemoteForward: |
709 | case oDynamicForward: | ||
709 | arg = strdelim(&s); | 710 | arg = strdelim(&s); |
710 | if (arg == NULL || *arg == '\0') | 711 | if (arg == NULL || *arg == '\0') |
711 | fatal("%.200s line %d: Missing port argument.", | 712 | fatal("%.200s line %d: Missing port argument.", |
712 | filename, linenum); | 713 | filename, linenum); |
713 | arg2 = strdelim(&s); | ||
714 | if (arg2 == NULL || *arg2 == '\0') | ||
715 | fatal("%.200s line %d: Missing target argument.", | ||
716 | filename, linenum); | ||
717 | 714 | ||
718 | /* construct a string for parse_forward */ | 715 | if (opcode == oLocalForward || |
719 | snprintf(fwdarg, sizeof(fwdarg), "%s:%s", arg, arg2); | 716 | opcode == oRemoteForward) { |
717 | arg2 = strdelim(&s); | ||
718 | if (arg2 == NULL || *arg2 == '\0') | ||
719 | fatal("%.200s line %d: Missing target argument.", | ||
720 | filename, linenum); | ||
720 | 721 | ||
721 | if (parse_forward(&fwd, fwdarg) == 0) | 722 | /* construct a string for parse_forward */ |
723 | snprintf(fwdarg, sizeof(fwdarg), "%s:%s", arg, arg2); | ||
724 | } else if (opcode == oDynamicForward) { | ||
725 | strlcpy(fwdarg, arg, sizeof(fwdarg)); | ||
726 | } | ||
727 | |||
728 | if (parse_forward(&fwd, fwdarg, | ||
729 | opcode == oDynamicForward ? 1 : 0) == 0) | ||
722 | fatal("%.200s line %d: Bad forwarding specification.", | 730 | fatal("%.200s line %d: Bad forwarding specification.", |
723 | filename, linenum); | 731 | filename, linenum); |
724 | 732 | ||
725 | if (*activep) { | 733 | if (*activep) { |
726 | if (opcode == oLocalForward) | 734 | if (opcode == oLocalForward || |
735 | opcode == oDynamicForward) | ||
727 | add_local_forward(options, &fwd); | 736 | add_local_forward(options, &fwd); |
728 | else if (opcode == oRemoteForward) | 737 | else if (opcode == oRemoteForward) |
729 | add_remote_forward(options, &fwd); | 738 | add_remote_forward(options, &fwd); |
730 | } | 739 | } |
731 | break; | 740 | break; |
732 | 741 | ||
733 | case oDynamicForward: | ||
734 | arg = strdelim(&s); | ||
735 | if (!arg || *arg == '\0') | ||
736 | fatal("%.200s line %d: Missing port argument.", | ||
737 | filename, linenum); | ||
738 | memset(&fwd, '\0', sizeof(fwd)); | ||
739 | fwd.connect_host = "socks"; | ||
740 | fwd.listen_host = hpdelim(&arg); | ||
741 | if (fwd.listen_host == NULL || | ||
742 | strlen(fwd.listen_host) >= NI_MAXHOST) | ||
743 | fatal("%.200s line %d: Bad forwarding specification.", | ||
744 | filename, linenum); | ||
745 | if (arg) { | ||
746 | fwd.listen_port = a2port(arg); | ||
747 | fwd.listen_host = cleanhostname(fwd.listen_host); | ||
748 | } else { | ||
749 | fwd.listen_port = a2port(fwd.listen_host); | ||
750 | fwd.listen_host = NULL; | ||
751 | } | ||
752 | if (fwd.listen_port == 0) | ||
753 | fatal("%.200s line %d: Badly formatted port number.", | ||
754 | filename, linenum); | ||
755 | if (*activep) | ||
756 | add_local_forward(options, &fwd); | ||
757 | break; | ||
758 | |||
759 | case oClearAllForwardings: | 742 | case oClearAllForwardings: |
760 | intptr = &options->clear_forwardings; | 743 | intptr = &options->clear_forwardings; |
761 | goto parse_flag; | 744 | goto parse_flag; |
@@ -1219,11 +1202,14 @@ fill_default_options(Options * options) | |||
1219 | /* | 1202 | /* |
1220 | * parse_forward | 1203 | * parse_forward |
1221 | * parses a string containing a port forwarding specification of the form: | 1204 | * parses a string containing a port forwarding specification of the form: |
1205 | * dynamicfwd == 0 | ||
1222 | * [listenhost:]listenport:connecthost:connectport | 1206 | * [listenhost:]listenport:connecthost:connectport |
1207 | * dynamicfwd == 1 | ||
1208 | * [listenhost:]listenport | ||
1223 | * returns number of arguments parsed or zero on error | 1209 | * returns number of arguments parsed or zero on error |
1224 | */ | 1210 | */ |
1225 | int | 1211 | int |
1226 | parse_forward(Forward *fwd, const char *fwdspec) | 1212 | parse_forward(Forward *fwd, const char *fwdspec, int dynamicfwd) |
1227 | { | 1213 | { |
1228 | int i; | 1214 | int i; |
1229 | char *p, *cp, *fwdarg[4]; | 1215 | char *p, *cp, *fwdarg[4]; |
@@ -1245,6 +1231,18 @@ parse_forward(Forward *fwd, const char *fwdspec) | |||
1245 | i = 0; /* failure */ | 1231 | i = 0; /* failure */ |
1246 | 1232 | ||
1247 | switch (i) { | 1233 | switch (i) { |
1234 | case 1: | ||
1235 | fwd->listen_host = NULL; | ||
1236 | fwd->listen_port = a2port(fwdarg[0]); | ||
1237 | fwd->connect_host = xstrdup("socks"); | ||
1238 | break; | ||
1239 | |||
1240 | case 2: | ||
1241 | fwd->listen_host = xstrdup(cleanhostname(fwdarg[0])); | ||
1242 | fwd->listen_port = a2port(fwdarg[1]); | ||
1243 | fwd->connect_host = xstrdup("socks"); | ||
1244 | break; | ||
1245 | |||
1248 | case 3: | 1246 | case 3: |
1249 | fwd->listen_host = NULL; | 1247 | fwd->listen_host = NULL; |
1250 | fwd->listen_port = a2port(fwdarg[0]); | 1248 | fwd->listen_port = a2port(fwdarg[0]); |
@@ -1264,7 +1262,17 @@ parse_forward(Forward *fwd, const char *fwdspec) | |||
1264 | 1262 | ||
1265 | xfree(p); | 1263 | xfree(p); |
1266 | 1264 | ||
1267 | if (fwd->listen_port == 0 || fwd->connect_port == 0) | 1265 | if (dynamicfwd) { |
1266 | if (!(i == 1 || i == 2)) | ||
1267 | goto fail_free; | ||
1268 | } else { | ||
1269 | if (!(i == 3 || i == 4)) | ||
1270 | goto fail_free; | ||
1271 | if (fwd->connect_port == 0) | ||
1272 | goto fail_free; | ||
1273 | } | ||
1274 | |||
1275 | if (fwd->listen_port == 0) | ||
1268 | goto fail_free; | 1276 | goto fail_free; |
1269 | 1277 | ||
1270 | if (fwd->connect_host != NULL && | 1278 | if (fwd->connect_host != NULL && |
diff --git a/readconf.h b/readconf.h index 47c7aef4e..c1387a896 100644 --- a/readconf.h +++ b/readconf.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.h,v 1.74 2008/06/26 11:46:31 grunk Exp $ */ | 1 | /* $OpenBSD: readconf.h,v 1.75 2008/11/01 17:40:33 stevesk Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -133,7 +133,7 @@ typedef struct { | |||
133 | void initialize_options(Options *); | 133 | void initialize_options(Options *); |
134 | void fill_default_options(Options *); | 134 | void fill_default_options(Options *); |
135 | int read_config_file(const char *, const char *, Options *, int); | 135 | int read_config_file(const char *, const char *, Options *, int); |
136 | int parse_forward(Forward *, const char *); | 136 | int parse_forward(Forward *, const char *, int); |
137 | 137 | ||
138 | int | 138 | int |
139 | process_config_line(Options *, const char *, char *, const char *, int, int *); | 139 | process_config_line(Options *, const char *, char *, const char *, int, int *); |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.321 2008/10/09 06:54:22 jmc Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.322 2008/11/01 17:40:33 stevesk 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 |
@@ -453,7 +453,7 @@ main(int ac, char **av) | |||
453 | break; | 453 | break; |
454 | 454 | ||
455 | case 'L': | 455 | case 'L': |
456 | if (parse_forward(&fwd, optarg)) | 456 | if (parse_forward(&fwd, optarg, 0)) |
457 | add_local_forward(&options, &fwd); | 457 | add_local_forward(&options, &fwd); |
458 | else { | 458 | else { |
459 | fprintf(stderr, | 459 | fprintf(stderr, |
@@ -464,7 +464,7 @@ main(int ac, char **av) | |||
464 | break; | 464 | break; |
465 | 465 | ||
466 | case 'R': | 466 | case 'R': |
467 | if (parse_forward(&fwd, optarg)) { | 467 | if (parse_forward(&fwd, optarg, 0)) { |
468 | add_remote_forward(&options, &fwd); | 468 | add_remote_forward(&options, &fwd); |
469 | } else { | 469 | } else { |
470 | fprintf(stderr, | 470 | fprintf(stderr, |
@@ -475,30 +475,14 @@ main(int ac, char **av) | |||
475 | break; | 475 | break; |
476 | 476 | ||
477 | case 'D': | 477 | case 'D': |
478 | cp = p = xstrdup(optarg); | 478 | if (parse_forward(&fwd, optarg, 1)) { |
479 | memset(&fwd, '\0', sizeof(fwd)); | 479 | add_local_forward(&options, &fwd); |
480 | fwd.connect_host = "socks"; | ||
481 | if ((fwd.listen_host = hpdelim(&cp)) == NULL) { | ||
482 | fprintf(stderr, "Bad dynamic forwarding " | ||
483 | "specification '%.100s'\n", optarg); | ||
484 | exit(255); | ||
485 | } | ||
486 | if (cp != NULL) { | ||
487 | fwd.listen_port = a2port(cp); | ||
488 | fwd.listen_host = | ||
489 | cleanhostname(fwd.listen_host); | ||
490 | } else { | 480 | } else { |
491 | fwd.listen_port = a2port(fwd.listen_host); | 481 | fprintf(stderr, |
492 | fwd.listen_host = NULL; | 482 | "Bad dynamic forwarding specification " |
493 | } | 483 | "'%s'\n", optarg); |
494 | |||
495 | if (fwd.listen_port == 0) { | ||
496 | fprintf(stderr, "Bad dynamic port '%s'\n", | ||
497 | optarg); | ||
498 | exit(255); | 484 | exit(255); |
499 | } | 485 | } |
500 | add_local_forward(&options, &fwd); | ||
501 | xfree(p); | ||
502 | break; | 486 | break; |
503 | 487 | ||
504 | case 'C': | 488 | case 'C': |