|
Lines 2218-2223
Link Here
|
| 2218 |
return success; |
2218 |
return success; |
| 2219 |
} |
2219 |
} |
| 2220 |
|
2220 |
|
|
|
2221 |
int |
| 2222 |
channel_cancel_rport_listener(const char *host, u_short port) |
| 2223 |
{ |
| 2224 |
int i, found = 0; |
| 2225 |
|
| 2226 |
for(i = 0; i < channels_alloc; i++) { |
| 2227 |
Channel *c = channels[i]; |
| 2228 |
|
| 2229 |
if (c != NULL && c->type == SSH_CHANNEL_RPORT_LISTENER) { |
| 2230 |
debug3("Channel %d %s:%d vs close msg %s:%d", |
| 2231 |
c->self, c->path, c->host_port, host, port); |
| 2232 |
if (strncmp(c->path, host, sizeof(c->path)) == 0 && |
| 2233 |
c->listening_port == port) { |
| 2234 |
debug2("%s: close clannel %d", __func__, i); |
| 2235 |
channel_free(c); |
| 2236 |
found = 1; |
| 2237 |
} |
| 2238 |
} |
| 2239 |
} |
| 2240 |
|
| 2241 |
return (found); |
| 2242 |
} |
| 2243 |
|
| 2221 |
/* protocol local port fwd, used by ssh (and sshd in v1) */ |
2244 |
/* protocol local port fwd, used by ssh (and sshd in v1) */ |
| 2222 |
int |
2245 |
int |
| 2223 |
channel_setup_local_fwd_listener(u_short listen_port, |
2246 |
channel_setup_local_fwd_listener(u_short listen_port, |
|
Lines 2295-2300
Link Here
|
| 2295 |
} |
2318 |
} |
| 2296 |
|
2319 |
|
| 2297 |
/* |
2320 |
/* |
|
|
2321 |
* Request cancellation of remote forwarding of connection host:port from |
| 2322 |
* local side. |
| 2323 |
*/ |
| 2324 |
|
| 2325 |
void |
| 2326 |
channel_request_rforward_cancel(u_short port) |
| 2327 |
{ |
| 2328 |
int i; |
| 2329 |
const char *address_to_bind = "0.0.0.0"; |
| 2330 |
|
| 2331 |
if (!compat20) |
| 2332 |
return; |
| 2333 |
|
| 2334 |
for (i = 0; i < num_permitted_opens; i++) { |
| 2335 |
if (permitted_opens[i].host_to_connect != NULL && |
| 2336 |
permitted_opens[i].listen_port == port) |
| 2337 |
break; |
| 2338 |
} |
| 2339 |
if (i >= num_permitted_opens) { |
| 2340 |
debug("%s: requested forward not found", __func__); |
| 2341 |
return; |
| 2342 |
} |
| 2343 |
packet_start(SSH2_MSG_GLOBAL_REQUEST); |
| 2344 |
packet_put_cstring("cancel-tcpip-forward"); |
| 2345 |
packet_put_char(0); |
| 2346 |
packet_put_cstring(address_to_bind); |
| 2347 |
packet_put_int(port); |
| 2348 |
packet_send(); |
| 2349 |
|
| 2350 |
permitted_opens[i].listen_port = 0; |
| 2351 |
permitted_opens[i].port_to_connect = 0; |
| 2352 |
free(permitted_opens[i].host_to_connect); |
| 2353 |
permitted_opens[i].host_to_connect = NULL; |
| 2354 |
} |
| 2355 |
|
| 2356 |
/* |
| 2298 |
* This is called after receiving CHANNEL_FORWARDING_REQUEST. This initates |
2357 |
* This is called after receiving CHANNEL_FORWARDING_REQUEST. This initates |
| 2299 |
* listening for the port, and sends back a success reply (or disconnect |
2358 |
* listening for the port, and sends back a success reply (or disconnect |
| 2300 |
* message if there was an error). This never returns if there was an error. |
2359 |
* message if there was an error). This never returns if there was an error. |
|
Lines 2361-2367
Link Here
|
| 2361 |
int i; |
2420 |
int i; |
| 2362 |
|
2421 |
|
| 2363 |
for (i = 0; i < num_permitted_opens; i++) |
2422 |
for (i = 0; i < num_permitted_opens; i++) |
| 2364 |
xfree(permitted_opens[i].host_to_connect); |
2423 |
if (permitted_opens[i].host_to_connect != NULL) |
|
|
2424 |
xfree(permitted_opens[i].host_to_connect); |
| 2365 |
num_permitted_opens = 0; |
2425 |
num_permitted_opens = 0; |
| 2366 |
|
2426 |
|
| 2367 |
} |
2427 |
} |
|
Lines 2429-2435
Link Here
|
| 2429 |
int i; |
2489 |
int i; |
| 2430 |
|
2490 |
|
| 2431 |
for (i = 0; i < num_permitted_opens; i++) |
2491 |
for (i = 0; i < num_permitted_opens; i++) |
| 2432 |
if (permitted_opens[i].listen_port == listen_port) |
2492 |
if (permitted_opens[i].host_to_connect != NULL && |
|
|
2493 |
permitted_opens[i].listen_port == listen_port) |
| 2433 |
return connect_to( |
2494 |
return connect_to( |
| 2434 |
permitted_opens[i].host_to_connect, |
2495 |
permitted_opens[i].host_to_connect, |
| 2435 |
permitted_opens[i].port_to_connect); |
2496 |
permitted_opens[i].port_to_connect); |
|
Lines 2447-2453
Link Here
|
| 2447 |
permit = all_opens_permitted; |
2508 |
permit = all_opens_permitted; |
| 2448 |
if (!permit) { |
2509 |
if (!permit) { |
| 2449 |
for (i = 0; i < num_permitted_opens; i++) |
2510 |
for (i = 0; i < num_permitted_opens; i++) |
| 2450 |
if (permitted_opens[i].port_to_connect == port && |
2511 |
if (permitted_opens[i].host_to_connect != NULL && |
|
|
2512 |
permitted_opens[i].port_to_connect == port && |
| 2451 |
strcmp(permitted_opens[i].host_to_connect, host) == 0) |
2513 |
strcmp(permitted_opens[i].host_to_connect, host) == 0) |
| 2452 |
permit = 1; |
2514 |
permit = 1; |
| 2453 |
|
2515 |
|