mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-27 07:44:29 +02:00
- markus@cvs.openbsd.org 2002/01/16 13:17:51
[channels.c channels.h serverloop.c ssh.c] wrapper for channel_setup_fwd_listener
This commit is contained in:
parent
b51ed39161
commit
b16461ce45
@ -182,6 +182,9 @@
|
|||||||
- markus@cvs.openbsd.org 2002/01/14 13:57:03
|
- markus@cvs.openbsd.org 2002/01/14 13:57:03
|
||||||
[channels.h nchan.c]
|
[channels.h nchan.c]
|
||||||
(c) 2002
|
(c) 2002
|
||||||
|
- markus@cvs.openbsd.org 2002/01/16 13:17:51
|
||||||
|
[channels.c channels.h serverloop.c ssh.c]
|
||||||
|
wrapper for channel_setup_fwd_listener
|
||||||
|
|
||||||
20020121
|
20020121
|
||||||
- (djm) Rework ssh-rand-helper:
|
- (djm) Rework ssh-rand-helper:
|
||||||
@ -7329,4 +7332,4 @@
|
|||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1774 2002/01/22 12:29:03 djm Exp $
|
$Id: ChangeLog,v 1.1775 2002/01/22 12:29:22 djm Exp $
|
||||||
|
71
channels.c
71
channels.c
@ -39,7 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: channels.c,v 1.159 2002/01/14 13:55:55 markus Exp $");
|
RCSID("$OpenBSD: channels.c,v 1.160 2002/01/16 13:17:51 markus Exp $");
|
||||||
|
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
#include "ssh1.h"
|
#include "ssh1.h"
|
||||||
@ -2037,53 +2037,30 @@ channel_set_af(int af)
|
|||||||
IPv4or6 = af;
|
IPv4or6 = af;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int
|
||||||
* Initiate forwarding of connections to local port "port" through the secure
|
channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_port,
|
||||||
* channel to host:port from remote side.
|
const char *host_to_connect, u_short port_to_connect, int gateway_ports)
|
||||||
*/
|
|
||||||
int
|
|
||||||
channel_request_local_forwarding(u_short listen_port, const char *host_to_connect,
|
|
||||||
u_short port_to_connect, int gateway_ports)
|
|
||||||
{
|
|
||||||
return channel_request_forwarding(
|
|
||||||
NULL, listen_port,
|
|
||||||
host_to_connect, port_to_connect,
|
|
||||||
gateway_ports, /*remote_fwd*/ 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If 'remote_fwd' is true we have a '-R style' listener for protocol 2
|
|
||||||
* (SSH_CHANNEL_RPORT_LISTENER).
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
channel_request_forwarding(
|
|
||||||
const char *listen_address, u_short listen_port,
|
|
||||||
const char *host_to_connect, u_short port_to_connect,
|
|
||||||
int gateway_ports, int remote_fwd)
|
|
||||||
{
|
{
|
||||||
Channel *c;
|
Channel *c;
|
||||||
int success, sock, on = 1, type;
|
int success, sock, on = 1;
|
||||||
struct addrinfo hints, *ai, *aitop;
|
struct addrinfo hints, *ai, *aitop;
|
||||||
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
|
|
||||||
const char *host;
|
const char *host;
|
||||||
|
char ntop[NI_MAXHOST], strport[NI_MAXSERV];
|
||||||
struct linger linger;
|
struct linger linger;
|
||||||
|
|
||||||
success = 0;
|
success = 0;
|
||||||
|
host = (type == SSH_CHANNEL_RPORT_LISTENER) ?
|
||||||
|
listen_addr : host_to_connect;
|
||||||
|
|
||||||
if (remote_fwd) {
|
if (host == NULL) {
|
||||||
host = listen_address;
|
error("No forward host name.");
|
||||||
type = SSH_CHANNEL_RPORT_LISTENER;
|
return success;
|
||||||
} else {
|
|
||||||
host = host_to_connect;
|
|
||||||
type = SSH_CHANNEL_PORT_LISTENER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(host) > SSH_CHANNEL_PATH_LEN - 1) {
|
if (strlen(host) > SSH_CHANNEL_PATH_LEN - 1) {
|
||||||
error("Forward host name too long.");
|
error("Forward host name too long.");
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX listen_address is currently ignored */
|
|
||||||
/*
|
/*
|
||||||
* getaddrinfo returns a loopback address if the hostname is
|
* getaddrinfo returns a loopback address if the hostname is
|
||||||
* set to NULL and hints.ai_flags is not AI_PASSIVE
|
* set to NULL and hints.ai_flags is not AI_PASSIVE
|
||||||
@ -2101,7 +2078,7 @@ channel_request_forwarding(
|
|||||||
continue;
|
continue;
|
||||||
if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, sizeof(ntop),
|
if (getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop, sizeof(ntop),
|
||||||
strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
|
strport, sizeof(strport), NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
|
||||||
error("channel_request_forwarding: getnameinfo failed");
|
error("channel_setup_fwd_listener: getnameinfo failed");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Create a port to listen for the host. */
|
/* Create a port to listen for the host. */
|
||||||
@ -2143,7 +2120,7 @@ channel_request_forwarding(
|
|||||||
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
|
CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
|
||||||
0, xstrdup("port listener"), 1);
|
0, xstrdup("port listener"), 1);
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
error("channel_request_forwarding: channel_new failed");
|
error("channel_setup_fwd_listener: channel_new failed");
|
||||||
close(sock);
|
close(sock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2153,12 +2130,30 @@ channel_request_forwarding(
|
|||||||
success = 1;
|
success = 1;
|
||||||
}
|
}
|
||||||
if (success == 0)
|
if (success == 0)
|
||||||
error("channel_request_forwarding: cannot listen to port: %d",
|
error("channel_setup_fwd_listener: cannot listen to port: %d",
|
||||||
listen_port);
|
listen_port);
|
||||||
freeaddrinfo(aitop);
|
freeaddrinfo(aitop);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* protocol local port fwd, used by ssh (and sshd in v1) */
|
||||||
|
int
|
||||||
|
channel_setup_local_fwd_listener(u_short listen_port,
|
||||||
|
const char *host_to_connect, u_short port_to_connect, int gateway_ports)
|
||||||
|
{
|
||||||
|
return channel_setup_fwd_listener(SSH_CHANNEL_PORT_LISTENER,
|
||||||
|
NULL, listen_port, host_to_connect, port_to_connect, gateway_ports);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* protocol v2 remote port fwd, used by sshd */
|
||||||
|
int
|
||||||
|
channel_setup_remote_fwd_listener(const char *listen_address,
|
||||||
|
u_short listen_port, int gateway_ports)
|
||||||
|
{
|
||||||
|
return channel_setup_fwd_listener(SSH_CHANNEL_RPORT_LISTENER,
|
||||||
|
listen_address, listen_port, NULL, 0, gateway_ports);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initiate forwarding of connections to port "port" on remote host through
|
* Initiate forwarding of connections to port "port" on remote host through
|
||||||
* the secure channel to host:port from local side.
|
* the secure channel to host:port from local side.
|
||||||
@ -2244,7 +2239,7 @@ channel_input_port_forward_request(int is_root, int gateway_ports)
|
|||||||
port);
|
port);
|
||||||
#endif
|
#endif
|
||||||
/* Initiate forwarding */
|
/* Initiate forwarding */
|
||||||
channel_request_local_forwarding(port, hostname, host_port, gateway_ports);
|
channel_setup_local_fwd_listener(port, hostname, host_port, gateway_ports);
|
||||||
|
|
||||||
/* Free the argument string. */
|
/* Free the argument string. */
|
||||||
xfree(hostname);
|
xfree(hostname);
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* RCSID("$OpenBSD: channels.h,v 1.59 2002/01/14 13:57:03 markus Exp $"); */
|
/* RCSID("$OpenBSD: channels.h,v 1.60 2002/01/16 13:17:51 markus Exp $"); */
|
||||||
|
|
||||||
#ifndef CHANNEL_H
|
#ifndef CHANNEL_H
|
||||||
#define CHANNEL_H
|
#define CHANNEL_H
|
||||||
@ -190,10 +190,8 @@ void channel_input_port_forward_request(int, int);
|
|||||||
int channel_connect_to(const char *, u_short);
|
int channel_connect_to(const char *, u_short);
|
||||||
int channel_connect_by_listen_address(u_short);
|
int channel_connect_by_listen_address(u_short);
|
||||||
void channel_request_remote_forwarding(u_short, const char *, u_short);
|
void channel_request_remote_forwarding(u_short, const char *, u_short);
|
||||||
int channel_request_local_forwarding(u_short, const char *, u_short, int);
|
int channel_setup_local_fwd_listener(u_short, const char *, u_short, int);
|
||||||
int
|
int channel_setup_remote_fwd_listener(const char *, u_short, int);
|
||||||
channel_request_forwarding(const char *, u_short, const char *, u_short, int,
|
|
||||||
int);
|
|
||||||
|
|
||||||
/* x11 forwarding */
|
/* x11 forwarding */
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: serverloop.c,v 1.94 2002/01/10 11:13:29 markus Exp $");
|
RCSID("$OpenBSD: serverloop.c,v 1.95 2002/01/16 13:17:51 markus Exp $");
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
@ -991,11 +991,8 @@ server_input_global_request(int type, u_int32_t seq, void *ctxt)
|
|||||||
packet_send_debug("Server has disabled port forwarding.");
|
packet_send_debug("Server has disabled port forwarding.");
|
||||||
} else {
|
} else {
|
||||||
/* Start listening on the port */
|
/* Start listening on the port */
|
||||||
success = channel_request_forwarding(
|
success = channel_setup_remote_fwd_listener(
|
||||||
listen_address, listen_port,
|
listen_address, listen_port, options.gateway_ports);
|
||||||
/*unspec host_to_connect*/ "<unspec host>",
|
|
||||||
/*unspec port_to_connect*/ 0,
|
|
||||||
options.gateway_ports, /*remote*/ 1);
|
|
||||||
}
|
}
|
||||||
xfree(listen_address);
|
xfree(listen_address);
|
||||||
}
|
}
|
||||||
|
4
ssh.c
4
ssh.c
@ -39,7 +39,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
RCSID("$OpenBSD: ssh.c,v 1.157 2001/12/28 15:06:00 markus Exp $");
|
RCSID("$OpenBSD: ssh.c,v 1.158 2002/01/16 13:17:51 markus Exp $");
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@ -841,7 +841,7 @@ ssh_init_forwarding(void)
|
|||||||
options.local_forwards[i].port,
|
options.local_forwards[i].port,
|
||||||
options.local_forwards[i].host,
|
options.local_forwards[i].host,
|
||||||
options.local_forwards[i].host_port);
|
options.local_forwards[i].host_port);
|
||||||
success += channel_request_local_forwarding(
|
success += channel_setup_local_fwd_listener(
|
||||||
options.local_forwards[i].port,
|
options.local_forwards[i].port,
|
||||||
options.local_forwards[i].host,
|
options.local_forwards[i].host,
|
||||||
options.local_forwards[i].host_port,
|
options.local_forwards[i].host_port,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user