diff options
author | Colin Watson <cjwatson@debian.org> | 2010-01-01 17:15:23 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2010-01-01 17:15:23 +0000 |
commit | 99b402ea4c8457b0a3cafff37f5b3410a8dc6476 (patch) | |
tree | 1d24ce54c9981ea8cbb4c5a9309964a0e4c4b320 /ssh.c | |
parent | 87552344215a38d3a2b0d4d63dc151e05978bbe1 (diff) | |
parent | 54af7a4ae8d455791a631bdfaade4b64436ae16a (diff) |
import openssh-5.2p1-gsskex-all-20090726.patch
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 58 |
1 files changed, 27 insertions, 31 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.318 2008/07/02 13:47:39 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.324 2009/02/12 03:00:56 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 |
@@ -179,7 +179,7 @@ static void | |||
179 | usage(void) | 179 | usage(void) |
180 | { | 180 | { |
181 | fprintf(stderr, | 181 | fprintf(stderr, |
182 | "usage: ssh [-1246AaCfgKkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]\n" | 182 | "usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]\n" |
183 | " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" | 183 | " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" |
184 | " [-i identity_file] [-L [bind_address:]port:host:hostport]\n" | 184 | " [-i identity_file] [-L [bind_address:]port:host:hostport]\n" |
185 | " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" | 185 | " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" |
@@ -203,7 +203,7 @@ void muxserver_listen(void); | |||
203 | int | 203 | int |
204 | main(int ac, char **av) | 204 | main(int ac, char **av) |
205 | { | 205 | { |
206 | int i, opt, exit_status; | 206 | int i, opt, exit_status, use_syslog; |
207 | char *p, *cp, *line, buf[256]; | 207 | char *p, *cp, *line, buf[256]; |
208 | struct stat st; | 208 | struct stat st; |
209 | struct passwd *pw; | 209 | struct passwd *pw; |
@@ -269,10 +269,11 @@ main(int ac, char **av) | |||
269 | 269 | ||
270 | /* Parse command-line arguments. */ | 270 | /* Parse command-line arguments. */ |
271 | host = NULL; | 271 | host = NULL; |
272 | use_syslog = 0; | ||
272 | 273 | ||
273 | again: | 274 | again: |
274 | while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" | 275 | while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" |
275 | "ACD:F:I:KL:MNO:PR:S:TVw:XY")) != -1) { | 276 | "ACD:F:I:KL:MNO:PR:S:TVw:XYy")) != -1) { |
276 | switch (opt) { | 277 | switch (opt) { |
277 | case '1': | 278 | case '1': |
278 | options.protocol = SSH_PROTO_1; | 279 | options.protocol = SSH_PROTO_1; |
@@ -299,6 +300,9 @@ main(int ac, char **av) | |||
299 | case 'X': | 300 | case 'X': |
300 | options.forward_x11 = 1; | 301 | options.forward_x11 = 1; |
301 | break; | 302 | break; |
303 | case 'y': | ||
304 | use_syslog = 1; | ||
305 | break; | ||
302 | case 'Y': | 306 | case 'Y': |
303 | options.forward_x11 = 1; | 307 | options.forward_x11 = 1; |
304 | options.forward_x11_trusted = 1; | 308 | options.forward_x11_trusted = 1; |
@@ -439,7 +443,7 @@ main(int ac, char **av) | |||
439 | break; | 443 | break; |
440 | case 'p': | 444 | case 'p': |
441 | options.port = a2port(optarg); | 445 | options.port = a2port(optarg); |
442 | if (options.port == 0) { | 446 | if (options.port <= 0) { |
443 | fprintf(stderr, "Bad port '%s'\n", optarg); | 447 | fprintf(stderr, "Bad port '%s'\n", optarg); |
444 | exit(255); | 448 | exit(255); |
445 | } | 449 | } |
@@ -449,7 +453,7 @@ main(int ac, char **av) | |||
449 | break; | 453 | break; |
450 | 454 | ||
451 | case 'L': | 455 | case 'L': |
452 | if (parse_forward(&fwd, optarg)) | 456 | if (parse_forward(&fwd, optarg, 0, 0)) |
453 | add_local_forward(&options, &fwd); | 457 | add_local_forward(&options, &fwd); |
454 | else { | 458 | else { |
455 | fprintf(stderr, | 459 | fprintf(stderr, |
@@ -460,7 +464,7 @@ main(int ac, char **av) | |||
460 | break; | 464 | break; |
461 | 465 | ||
462 | case 'R': | 466 | case 'R': |
463 | if (parse_forward(&fwd, optarg)) { | 467 | if (parse_forward(&fwd, optarg, 0, 1)) { |
464 | add_remote_forward(&options, &fwd); | 468 | add_remote_forward(&options, &fwd); |
465 | } else { | 469 | } else { |
466 | fprintf(stderr, | 470 | fprintf(stderr, |
@@ -471,30 +475,14 @@ main(int ac, char **av) | |||
471 | break; | 475 | break; |
472 | 476 | ||
473 | case 'D': | 477 | case 'D': |
474 | cp = p = xstrdup(optarg); | 478 | if (parse_forward(&fwd, optarg, 1, 0)) { |
475 | memset(&fwd, '\0', sizeof(fwd)); | 479 | add_local_forward(&options, &fwd); |
476 | fwd.connect_host = "socks"; | ||
477 | if ((fwd.listen_host = hpdelim(&cp)) == NULL) { | ||
478 | fprintf(stderr, "Bad dynamic forwarding " | ||
479 | "specification '%.100s'\n", optarg); | ||
480 | exit(255); | ||
481 | } | ||
482 | if (cp != NULL) { | ||
483 | fwd.listen_port = a2port(cp); | ||
484 | fwd.listen_host = | ||
485 | cleanhostname(fwd.listen_host); | ||
486 | } else { | 480 | } else { |
487 | fwd.listen_port = a2port(fwd.listen_host); | 481 | fprintf(stderr, |
488 | fwd.listen_host = NULL; | 482 | "Bad dynamic forwarding specification " |
489 | } | 483 | "'%s'\n", optarg); |
490 | |||
491 | if (fwd.listen_port == 0) { | ||
492 | fprintf(stderr, "Bad dynamic port '%s'\n", | ||
493 | optarg); | ||
494 | exit(255); | 484 | exit(255); |
495 | } | 485 | } |
496 | add_local_forward(&options, &fwd); | ||
497 | xfree(p); | ||
498 | break; | 486 | break; |
499 | 487 | ||
500 | case 'C': | 488 | case 'C': |
@@ -614,7 +602,7 @@ main(int ac, char **av) | |||
614 | */ | 602 | */ |
615 | log_init(av[0], | 603 | log_init(av[0], |
616 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, | 604 | options.log_level == -1 ? SYSLOG_LEVEL_INFO : options.log_level, |
617 | SYSLOG_FACILITY_USER, 1); | 605 | SYSLOG_FACILITY_USER, !use_syslog); |
618 | 606 | ||
619 | /* | 607 | /* |
620 | * Read per-user configuration file. Ignore the system wide config | 608 | * Read per-user configuration file. Ignore the system wide config |
@@ -640,7 +628,7 @@ main(int ac, char **av) | |||
640 | channel_set_af(options.address_family); | 628 | channel_set_af(options.address_family); |
641 | 629 | ||
642 | /* reinit */ | 630 | /* reinit */ |
643 | log_init(av[0], options.log_level, SYSLOG_FACILITY_USER, 1); | 631 | log_init(av[0], options.log_level, SYSLOG_FACILITY_USER, !use_syslog); |
644 | 632 | ||
645 | seed_rng(); | 633 | seed_rng(); |
646 | 634 | ||
@@ -849,9 +837,16 @@ ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt) | |||
849 | { | 837 | { |
850 | Forward *rfwd = (Forward *)ctxt; | 838 | Forward *rfwd = (Forward *)ctxt; |
851 | 839 | ||
840 | /* XXX verbose() on failure? */ | ||
852 | debug("remote forward %s for: listen %d, connect %s:%d", | 841 | debug("remote forward %s for: listen %d, connect %s:%d", |
853 | type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure", | 842 | type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure", |
854 | rfwd->listen_port, rfwd->connect_host, rfwd->connect_port); | 843 | rfwd->listen_port, rfwd->connect_host, rfwd->connect_port); |
844 | if (type == SSH2_MSG_REQUEST_SUCCESS && rfwd->listen_port == 0) { | ||
845 | logit("Allocated port %u for remote forward to %s:%d", | ||
846 | packet_get_int(), | ||
847 | rfwd->connect_host, rfwd->connect_port); | ||
848 | } | ||
849 | |||
855 | if (type == SSH2_MSG_REQUEST_FAILURE) { | 850 | if (type == SSH2_MSG_REQUEST_FAILURE) { |
856 | if (options.exit_on_forward_failure) | 851 | if (options.exit_on_forward_failure) |
857 | fatal("Error: remote port forwarding failed for " | 852 | fatal("Error: remote port forwarding failed for " |
@@ -1200,7 +1195,8 @@ ssh_session2(void) | |||
1200 | id = ssh_session2_open(); | 1195 | id = ssh_session2_open(); |
1201 | 1196 | ||
1202 | /* If we don't expect to open a new session, then disallow it */ | 1197 | /* If we don't expect to open a new session, then disallow it */ |
1203 | if (options.control_master == SSHCTL_MASTER_NO) { | 1198 | if (options.control_master == SSHCTL_MASTER_NO && |
1199 | (datafellows & SSH_NEW_OPENSSH)) { | ||
1204 | debug("Requesting no-more-sessions@openssh.com"); | 1200 | debug("Requesting no-more-sessions@openssh.com"); |
1205 | packet_start(SSH2_MSG_GLOBAL_REQUEST); | 1201 | packet_start(SSH2_MSG_GLOBAL_REQUEST); |
1206 | packet_put_cstring("no-more-sessions@openssh.com"); | 1202 | packet_put_cstring("no-more-sessions@openssh.com"); |