diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 62 |
1 files changed, 37 insertions, 25 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.405 2014/07/03 06:39:19 djm Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.406 2014/07/15 15:54:14 millert 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 |
@@ -96,9 +96,9 @@ | |||
96 | #include "dispatch.h" | 96 | #include "dispatch.h" |
97 | #include "clientloop.h" | 97 | #include "clientloop.h" |
98 | #include "log.h" | 98 | #include "log.h" |
99 | #include "misc.h" | ||
99 | #include "readconf.h" | 100 | #include "readconf.h" |
100 | #include "sshconnect.h" | 101 | #include "sshconnect.h" |
101 | #include "misc.h" | ||
102 | #include "kex.h" | 102 | #include "kex.h" |
103 | #include "mac.h" | 103 | #include "mac.h" |
104 | #include "sshpty.h" | 104 | #include "sshpty.h" |
@@ -423,7 +423,7 @@ main(int ac, char **av) | |||
423 | int timeout_ms; | 423 | int timeout_ms; |
424 | extern int optind, optreset; | 424 | extern int optind, optreset; |
425 | extern char *optarg; | 425 | extern char *optarg; |
426 | Forward fwd; | 426 | struct Forward fwd; |
427 | struct addrinfo *addrs = NULL; | 427 | struct addrinfo *addrs = NULL; |
428 | struct ssh_digest_ctx *md; | 428 | struct ssh_digest_ctx *md; |
429 | u_char conn_hash[SSH_DIGEST_MAX_LENGTH]; | 429 | u_char conn_hash[SSH_DIGEST_MAX_LENGTH]; |
@@ -545,7 +545,7 @@ main(int ac, char **av) | |||
545 | options.forward_x11_trusted = 1; | 545 | options.forward_x11_trusted = 1; |
546 | break; | 546 | break; |
547 | case 'g': | 547 | case 'g': |
548 | options.gateway_ports = 1; | 548 | options.fwd_opts.gateway_ports = 1; |
549 | break; | 549 | break; |
550 | case 'O': | 550 | case 'O': |
551 | if (stdio_forward_host != NULL) | 551 | if (stdio_forward_host != NULL) |
@@ -1305,15 +1305,17 @@ fork_postauth(void) | |||
1305 | static void | 1305 | static void |
1306 | ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt) | 1306 | ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt) |
1307 | { | 1307 | { |
1308 | Forward *rfwd = (Forward *)ctxt; | 1308 | struct Forward *rfwd = (struct Forward *)ctxt; |
1309 | 1309 | ||
1310 | /* XXX verbose() on failure? */ | 1310 | /* XXX verbose() on failure? */ |
1311 | debug("remote forward %s for: listen %s%s%d, connect %s:%d", | 1311 | debug("remote forward %s for: listen %s%s%d, connect %s:%d", |
1312 | type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure", | 1312 | type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure", |
1313 | rfwd->listen_host == NULL ? "" : rfwd->listen_host, | 1313 | rfwd->listen_path ? rfwd->listen_path : |
1314 | rfwd->listen_host == NULL ? "" : ":", | 1314 | rfwd->listen_host ? rfwd->listen_host : "", |
1315 | rfwd->listen_port, rfwd->connect_host, rfwd->connect_port); | 1315 | (rfwd->listen_path || rfwd->listen_host) ? ":" : "", |
1316 | if (rfwd->listen_port == 0) { | 1316 | rfwd->listen_port, rfwd->connect_path ? rfwd->connect_path : |
1317 | rfwd->connect_host, rfwd->connect_port); | ||
1318 | if (rfwd->listen_path == NULL && rfwd->listen_port == 0) { | ||
1317 | if (type == SSH2_MSG_REQUEST_SUCCESS) { | 1319 | if (type == SSH2_MSG_REQUEST_SUCCESS) { |
1318 | rfwd->allocated_port = packet_get_int(); | 1320 | rfwd->allocated_port = packet_get_int(); |
1319 | logit("Allocated port %u for remote forward to %s:%d", | 1321 | logit("Allocated port %u for remote forward to %s:%d", |
@@ -1327,12 +1329,21 @@ ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt) | |||
1327 | } | 1329 | } |
1328 | 1330 | ||
1329 | if (type == SSH2_MSG_REQUEST_FAILURE) { | 1331 | if (type == SSH2_MSG_REQUEST_FAILURE) { |
1330 | if (options.exit_on_forward_failure) | 1332 | if (options.exit_on_forward_failure) { |
1331 | fatal("Error: remote port forwarding failed for " | 1333 | if (rfwd->listen_path != NULL) |
1332 | "listen port %d", rfwd->listen_port); | 1334 | fatal("Error: remote port forwarding failed " |
1333 | else | 1335 | "for listen path %s", rfwd->listen_path); |
1334 | logit("Warning: remote port forwarding failed for " | 1336 | else |
1335 | "listen port %d", rfwd->listen_port); | 1337 | fatal("Error: remote port forwarding failed " |
1338 | "for listen port %d", rfwd->listen_port); | ||
1339 | } else { | ||
1340 | if (rfwd->listen_path != NULL) | ||
1341 | logit("Warning: remote port forwarding failed " | ||
1342 | "for listen path %s", rfwd->listen_path); | ||
1343 | else | ||
1344 | logit("Warning: remote port forwarding failed " | ||
1345 | "for listen port %d", rfwd->listen_port); | ||
1346 | } | ||
1336 | } | 1347 | } |
1337 | if (++remote_forward_confirms_received == options.num_remote_forwards) { | 1348 | if (++remote_forward_confirms_received == options.num_remote_forwards) { |
1338 | debug("All remote forwarding requests processed"); | 1349 | debug("All remote forwarding requests processed"); |
@@ -1380,18 +1391,18 @@ ssh_init_forwarding(void) | |||
1380 | for (i = 0; i < options.num_local_forwards; i++) { | 1391 | for (i = 0; i < options.num_local_forwards; i++) { |
1381 | debug("Local connections to %.200s:%d forwarded to remote " | 1392 | debug("Local connections to %.200s:%d forwarded to remote " |
1382 | "address %.200s:%d", | 1393 | "address %.200s:%d", |
1394 | (options.local_forwards[i].listen_path != NULL) ? | ||
1395 | options.local_forwards[i].listen_path : | ||
1383 | (options.local_forwards[i].listen_host == NULL) ? | 1396 | (options.local_forwards[i].listen_host == NULL) ? |
1384 | (options.gateway_ports ? "*" : "LOCALHOST") : | 1397 | (options.fwd_opts.gateway_ports ? "*" : "LOCALHOST") : |
1385 | options.local_forwards[i].listen_host, | 1398 | options.local_forwards[i].listen_host, |
1386 | options.local_forwards[i].listen_port, | 1399 | options.local_forwards[i].listen_port, |
1400 | (options.local_forwards[i].connect_path != NULL) ? | ||
1401 | options.local_forwards[i].connect_path : | ||
1387 | options.local_forwards[i].connect_host, | 1402 | options.local_forwards[i].connect_host, |
1388 | options.local_forwards[i].connect_port); | 1403 | options.local_forwards[i].connect_port); |
1389 | success += channel_setup_local_fwd_listener( | 1404 | success += channel_setup_local_fwd_listener( |
1390 | options.local_forwards[i].listen_host, | 1405 | &options.local_forwards[i], &options.fwd_opts); |
1391 | options.local_forwards[i].listen_port, | ||
1392 | options.local_forwards[i].connect_host, | ||
1393 | options.local_forwards[i].connect_port, | ||
1394 | options.gateway_ports); | ||
1395 | } | 1406 | } |
1396 | if (i > 0 && success != i && options.exit_on_forward_failure) | 1407 | if (i > 0 && success != i && options.exit_on_forward_failure) |
1397 | fatal("Could not request local forwarding."); | 1408 | fatal("Could not request local forwarding."); |
@@ -1402,17 +1413,18 @@ ssh_init_forwarding(void) | |||
1402 | for (i = 0; i < options.num_remote_forwards; i++) { | 1413 | for (i = 0; i < options.num_remote_forwards; i++) { |
1403 | debug("Remote connections from %.200s:%d forwarded to " | 1414 | debug("Remote connections from %.200s:%d forwarded to " |
1404 | "local address %.200s:%d", | 1415 | "local address %.200s:%d", |
1416 | (options.remote_forwards[i].listen_path != NULL) ? | ||
1417 | options.remote_forwards[i].listen_path : | ||
1405 | (options.remote_forwards[i].listen_host == NULL) ? | 1418 | (options.remote_forwards[i].listen_host == NULL) ? |
1406 | "LOCALHOST" : options.remote_forwards[i].listen_host, | 1419 | "LOCALHOST" : options.remote_forwards[i].listen_host, |
1407 | options.remote_forwards[i].listen_port, | 1420 | options.remote_forwards[i].listen_port, |
1421 | (options.remote_forwards[i].connect_path != NULL) ? | ||
1422 | options.remote_forwards[i].connect_path : | ||
1408 | options.remote_forwards[i].connect_host, | 1423 | options.remote_forwards[i].connect_host, |
1409 | options.remote_forwards[i].connect_port); | 1424 | options.remote_forwards[i].connect_port); |
1410 | options.remote_forwards[i].handle = | 1425 | options.remote_forwards[i].handle = |
1411 | channel_request_remote_forwarding( | 1426 | channel_request_remote_forwarding( |
1412 | options.remote_forwards[i].listen_host, | 1427 | &options.remote_forwards[i]); |
1413 | options.remote_forwards[i].listen_port, | ||
1414 | options.remote_forwards[i].connect_host, | ||
1415 | options.remote_forwards[i].connect_port); | ||
1416 | if (options.remote_forwards[i].handle < 0) { | 1428 | if (options.remote_forwards[i].handle < 0) { |
1417 | if (options.exit_on_forward_failure) | 1429 | if (options.exit_on_forward_failure) |
1418 | fatal("Could not request remote forwarding."); | 1430 | fatal("Could not request remote forwarding."); |