summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/channels.c b/channels.c
index a1c31d8a0..e741f29b9 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.327 2013/11/08 00:39:15 djm Exp $ */ 1/* $OpenBSD: channels.c,v 1.328 2013/12/19 01:04:36 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
@@ -1385,6 +1385,8 @@ port_open_helper(Channel *c, char *rtype)
1385{ 1385{
1386 int direct; 1386 int direct;
1387 char buf[1024]; 1387 char buf[1024];
1388 char *local_ipaddr = get_local_ipaddr(c->sock);
1389 int local_port = get_sock_port(c->sock, 1);
1388 char *remote_ipaddr = get_peer_ipaddr(c->sock); 1390 char *remote_ipaddr = get_peer_ipaddr(c->sock);
1389 int remote_port = get_peer_port(c->sock); 1391 int remote_port = get_peer_port(c->sock);
1390 1392
@@ -1399,9 +1401,9 @@ port_open_helper(Channel *c, char *rtype)
1399 1401
1400 snprintf(buf, sizeof buf, 1402 snprintf(buf, sizeof buf,
1401 "%s: listening port %d for %.100s port %d, " 1403 "%s: listening port %d for %.100s port %d, "
1402 "connect from %.200s port %d", 1404 "connect from %.200s port %d to %.100s port %d",
1403 rtype, c->listening_port, c->path, c->host_port, 1405 rtype, c->listening_port, c->path, c->host_port,
1404 remote_ipaddr, remote_port); 1406 remote_ipaddr, remote_port, local_ipaddr, local_port);
1405 1407
1406 free(c->remote_name); 1408 free(c->remote_name);
1407 c->remote_name = xstrdup(buf); 1409 c->remote_name = xstrdup(buf);
@@ -1419,7 +1421,7 @@ port_open_helper(Channel *c, char *rtype)
1419 } else { 1421 } else {
1420 /* listen address, port */ 1422 /* listen address, port */
1421 packet_put_cstring(c->path); 1423 packet_put_cstring(c->path);
1422 packet_put_int(c->listening_port); 1424 packet_put_int(local_port);
1423 } 1425 }
1424 /* originator host and port */ 1426 /* originator host and port */
1425 packet_put_cstring(remote_ipaddr); 1427 packet_put_cstring(remote_ipaddr);
@@ -1436,6 +1438,7 @@ port_open_helper(Channel *c, char *rtype)
1436 packet_send(); 1438 packet_send();
1437 } 1439 }
1438 free(remote_ipaddr); 1440 free(remote_ipaddr);
1441 free(local_ipaddr);
1439} 1442}
1440 1443
1441static void 1444static void
@@ -2710,8 +2713,20 @@ channel_fwd_bind_addr(const char *listen_addr, int *wildcardp,
2710 if (((datafellows & SSH_OLD_FORWARD_ADDR) && 2713 if (((datafellows & SSH_OLD_FORWARD_ADDR) &&
2711 strcmp(listen_addr, "0.0.0.0") == 0 && is_client == 0) || 2714 strcmp(listen_addr, "0.0.0.0") == 0 && is_client == 0) ||
2712 *listen_addr == '\0' || strcmp(listen_addr, "*") == 0 || 2715 *listen_addr == '\0' || strcmp(listen_addr, "*") == 0 ||
2713 (!is_client && gateway_ports == 1)) 2716 (!is_client && gateway_ports == 1)) {
2714 wildcard = 1; 2717 wildcard = 1;
2718 /*
2719 * Notify client if they requested a specific listen
2720 * address and it was overridden.
2721 */
2722 if (*listen_addr != '\0' &&
2723 strcmp(listen_addr, "0.0.0.0") != 0 &&
2724 strcmp(listen_addr, "*") != 0) {
2725 packet_send_debug("Forwarding listen address "
2726 "\"%s\" overridden by server "
2727 "GatewayPorts", listen_addr);
2728 }
2729 }
2715 else if (strcmp(listen_addr, "localhost") != 0) 2730 else if (strcmp(listen_addr, "localhost") != 0)
2716 addr = listen_addr; 2731 addr = listen_addr;
2717 } 2732 }