summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/serverloop.c b/serverloop.c
index 77d9dee75..81cafe6ad 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.c,v 1.153 2008/06/30 12:15:39 djm Exp $ */ 1/* $OpenBSD: serverloop.c,v 1.157 2009/02/12 03:16:01 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
@@ -942,7 +942,7 @@ server_request_direct_tcpip(void)
942{ 942{
943 Channel *c; 943 Channel *c;
944 char *target, *originator; 944 char *target, *originator;
945 int target_port, originator_port; 945 u_short target_port, originator_port;
946 946
947 target = packet_get_string(NULL); 947 target = packet_get_string(NULL);
948 target_port = packet_get_int(); 948 target_port = packet_get_int();
@@ -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();
@@ -1117,7 +1117,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1117 1117
1118 /* check permissions */ 1118 /* check permissions */
1119 if (!options.allow_tcp_forwarding || 1119 if (!options.allow_tcp_forwarding ||
1120 no_port_forwarding_flag 1120 no_port_forwarding_flag ||
1121 (!want_reply && listen_port == 0)
1121#ifndef NO_IPPORT_RESERVED_CONCEPT 1122#ifndef NO_IPPORT_RESERVED_CONCEPT
1122 || (listen_port < IPPORT_RESERVED && pw->pw_uid != 0) 1123 || (listen_port < IPPORT_RESERVED && pw->pw_uid != 0)
1123#endif 1124#endif
@@ -1127,7 +1128,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1127 } else { 1128 } else {
1128 /* Start listening on the port */ 1129 /* Start listening on the port */
1129 success = channel_setup_remote_fwd_listener( 1130 success = channel_setup_remote_fwd_listener(
1130 listen_address, listen_port, options.gateway_ports); 1131 listen_address, listen_port,
1132 &allocated_listen_port, options.gateway_ports);
1131 } 1133 }
1132 xfree(listen_address); 1134 xfree(listen_address);
1133 } else if (strcmp(rtype, "cancel-tcpip-forward") == 0) { 1135 } else if (strcmp(rtype, "cancel-tcpip-forward") == 0) {
@@ -1149,6 +1151,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
1149 if (want_reply) { 1151 if (want_reply) {
1150 packet_start(success ? 1152 packet_start(success ?
1151 SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE); 1153 SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE);
1154 if (success && allocated_listen_port > 0)
1155 packet_put_int(allocated_listen_port);
1152 packet_send(); 1156 packet_send();
1153 packet_write_wait(); 1157 packet_write_wait();
1154 } 1158 }
@@ -1202,9 +1206,9 @@ server_init_dispatch_20(void)
1202 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &server_input_channel_req); 1206 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &server_input_channel_req);
1203 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 1207 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
1204 dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request); 1208 dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request);
1205 dispatch_set(SSH2_MSG_CHANNEL_SUCCESS, &channel_input_status_confirm);
1206 dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &channel_input_status_confirm);
1207 /* client_alive */ 1209 /* client_alive */
1210 dispatch_set(SSH2_MSG_CHANNEL_SUCCESS, &server_input_keep_alive);
1211 dispatch_set(SSH2_MSG_CHANNEL_FAILURE, &server_input_keep_alive);
1208 dispatch_set(SSH2_MSG_REQUEST_SUCCESS, &server_input_keep_alive); 1212 dispatch_set(SSH2_MSG_REQUEST_SUCCESS, &server_input_keep_alive);
1209 dispatch_set(SSH2_MSG_REQUEST_FAILURE, &server_input_keep_alive); 1213 dispatch_set(SSH2_MSG_REQUEST_FAILURE, &server_input_keep_alive);
1210 /* rekeying */ 1214 /* rekeying */