summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2009-02-14 16:28:21 +1100
committerDamien Miller <djm@mindrot.org>2009-02-14 16:28:21 +1100
commit4bf648f7766ba764d7a78b1dbb26df4f0d42a8c9 (patch)
treecc576e28218cb3ad9617a12eabe68c21a7e09614 /serverloop.c
parentfdd66fc750228b5d040c45bc36565299374b72c8 (diff)
- 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 @@
1/* $OpenBSD: serverloop.c,v 1.155 2009/01/22 10:02:34 djm Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.156 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
@@ -1095,7 +1095,7 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1095{ 1095{
1096 char *rtype; 1096 char *rtype;
1097 int want_reply; 1097 int want_reply;
1098 int success = 0; 1098 int success = 0, allocated_listen_port = 0;
1099 1099
1100 rtype = packet_get_string(NULL); 1100 rtype = packet_get_string(NULL);
1101 want_reply = packet_get_char(); 1101 want_reply = packet_get_char();
@@ -1119,7 +1119,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1119 if (!options.allow_tcp_forwarding || 1119 if (!options.allow_tcp_forwarding ||
1120 no_port_forwarding_flag 1120 no_port_forwarding_flag
1121#ifndef NO_IPPORT_RESERVED_CONCEPT 1121#ifndef NO_IPPORT_RESERVED_CONCEPT
1122 || (listen_port < IPPORT_RESERVED && pw->pw_uid != 0) 1122 || (listen_port != 0 &&
1123 listen_port < IPPORT_RESERVED && pw->pw_uid != 0)
1123#endif 1124#endif
1124 ) { 1125 ) {
1125 success = 0; 1126 success = 0;
@@ -1149,6 +1150,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1149 if (want_reply) { 1150 if (want_reply) {
1150 packet_start(success ? 1151 packet_start(success ?
1151 SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE); 1152 SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
1153 if (success && allocated_listen_port > 0)
1154 packet_put_int(allocated_listen_port);
1152 packet_send(); 1155 packet_send();
1153 packet_write_wait(); 1156 packet_write_wait();
1154 } 1157 }