summaryrefslogtreecommitdiffstats
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2009-02-14 06:28:21 +0100
committerDamien Miller <djm@mindrot.org>2009-02-14 06:28:21 +0100
commit4bf648f7766ba764d7a78b1dbb26df4f0d42a8c9 (patch)
treecc576e28218cb3ad9617a12eabe68c21a7e09614 /serverloop.c
parent - dtucker@cvs.openbsd.org 2009/02/02 11:15:14 (diff)
downloadopenssh-4bf648f7766ba764d7a78b1dbb26df4f0d42a8c9.tar.xz
openssh-4bf648f7766ba764d7a78b1dbb26df4f0d42a8c9.zip
- djm@cvs.openbsd.org 2009/02/12 03:00:56
[canohost.c canohost.h channels.c channels.h clientloop.c readconf.c] [readconf.h serverloop.c ssh.c] 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 'serverloop.c')
-rw-r--r--serverloop.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/serverloop.c b/serverloop.c
index 931779e30..6244ad71c 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: serverloop.c,v 1.155 2009/01/22 10:02:34 djm Exp $ */
+/* $OpenBSD: serverloop.c,v 1.156 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
@@ -1095,7 +1095,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
{
char *rtype;
int want_reply;
- int success = 0;
+ int success = 0, allocated_listen_port = 0;
rtype = packet_get_string(NULL);
want_reply = packet_get_char();
@@ -1119,7 +1119,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
if (!options.allow_tcp_forwarding ||
no_port_forwarding_flag
#ifndef NO_IPPORT_RESERVED_CONCEPT
- || (listen_port < IPPORT_RESERVED && pw->pw_uid != 0)
+ || (listen_port != 0 &&
+ listen_port < IPPORT_RESERVED && pw->pw_uid != 0)
#endif
) {
success = 0;
@@ -1149,6 +1150,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
if (want_reply) {
packet_start(success ?
SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
+ if (success && allocated_listen_port > 0)
+ packet_put_int(allocated_listen_port);
packet_send();
packet_write_wait();
}