summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/ssh.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2009-02-12 03:00:56 +0000
committerdjm <djm@openbsd.org>2009-02-12 03:00:56 +0000
commit4edc3fd2c0c4499a2e3c11aadcdd1240a3f9ce9c (patch)
treea3473e75393306cad3fb05e44a4eb66b768d37f9 /usr.bin/ssh/ssh.c
parentrevert pf.c r1.629 (which moved to this file) which was causing (diff)
downloadwireguard-openbsd-4edc3fd2c0c4499a2e3c11aadcdd1240a3f9ce9c.tar.xz
wireguard-openbsd-4edc3fd2c0c4499a2e3c11aadcdd1240a3f9ce9c.zip
support remote port forwarding with a zero listen port (-R0:...) to
dyamically allocate a listen port at runtime (this is actually specified in rfc4254); bz#1003 ok markus@
Diffstat (limited to 'usr.bin/ssh/ssh.c')
-rw-r--r--usr.bin/ssh/ssh.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/ssh/ssh.c b/usr.bin/ssh/ssh.c
index 912ff5e54dd..49cdfed145a 100644
--- a/usr.bin/ssh/ssh.c
+++ b/usr.bin/ssh/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.323 2009/01/22 10:02:34 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.324 2009/02/12 03:00:56 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -440,7 +440,7 @@ main(int ac, char **av)
break;
case 'L':
- if (parse_forward(&fwd, optarg, 0))
+ if (parse_forward(&fwd, optarg, 0, 0))
add_local_forward(&options, &fwd);
else {
fprintf(stderr,
@@ -451,7 +451,7 @@ main(int ac, char **av)
break;
case 'R':
- if (parse_forward(&fwd, optarg, 0)) {
+ if (parse_forward(&fwd, optarg, 0, 1)) {
add_remote_forward(&options, &fwd);
} else {
fprintf(stderr,
@@ -462,7 +462,7 @@ main(int ac, char **av)
break;
case 'D':
- if (parse_forward(&fwd, optarg, 1)) {
+ if (parse_forward(&fwd, optarg, 1, 0)) {
add_local_forward(&options, &fwd);
} else {
fprintf(stderr,
@@ -818,9 +818,16 @@ ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt)
{
Forward *rfwd = (Forward *)ctxt;
+ /* XXX verbose() on failure? */
debug("remote forward %s for: listen %d, connect %s:%d",
type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure",
rfwd->listen_port, rfwd->connect_host, rfwd->connect_port);
+ if (type == SSH2_MSG_REQUEST_SUCCESS && rfwd->listen_port == 0) {
+ logit("Allocated port %u for remote forward to %s:%d",
+ packet_get_int(),
+ rfwd->connect_host, rfwd->connect_port);
+ }
+
if (type == SSH2_MSG_REQUEST_FAILURE) {
if (options.exit_on_forward_failure)
fatal("Error: remote port forwarding failed for "