Commit 5ce82415 authored by Balázs Scheidler's avatar Balázs Scheidler Committed by Niels Möller
Browse files

Merged more of Bazsi's changes.

Rev: src/proxy_channel.c:1.2
Rev: src/proxy_channel.h:1.2
Rev: src/proxy_session.c:1.5
Rev: src/proxy_tcpforward.c:1.2
Rev: src/proxy_userauth.c:1.4
parent 56570e1a
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* lsh, an implementation of the ssh protocol /* lsh, an implementation of the ssh protocol
* *
* Copyright (C) 1999, 2000 Balzs Scheidler * Copyright (C) 1999 Balzs Scheidler
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
*/ */
#include "proxy_channel.h" #include "proxy_channel.h"
#include "xalloc.h"
#include "ssh.h"
#include "werror.h"
#include "channel_commands.h" #include "channel_commands.h"
#include "format.h" #include "format.h"
#include "ssh.h"
#include "werror.h"
#include "xalloc.h"
#define GABA_DEFINE #define GABA_DEFINE
#include "proxy_channel.h.x" #include "proxy_channel.h.x"
...@@ -34,7 +35,36 @@ ...@@ -34,7 +35,36 @@
#include "proxy_channel.c.x" #include "proxy_channel.c.x"
#define WINDOW_SIZE (SSH_MAX_PACKET << 3) #define WINDOW_SIZE 10000
#if 0
/* ;;GABA:
(class
(name proxy_flow_control)
(super flow_controlled)
(vars
(channel object proxy_channel)))
*/
static void
do_proxy_flow_control(struct flow_controlled *c,
UINT32 res UNUSED)
{
CAST(proxy_flow_control, closure, c);
CHANNEL_SEND(&closure->channel->super, NULL);
}
static struct flow_controlled *
make_proxy_flow_control(struct proxy_channel *channel)
{
NEW(proxy_flow_control, self);
self->super.report = do_proxy_flow_control;
self->channel = channel;
return &self->super;
}
#endif
static void static void
do_receive(struct ssh_channel *c, do_receive(struct ssh_channel *c,
...@@ -56,6 +86,15 @@ do_receive(struct ssh_channel *c, ...@@ -56,6 +86,15 @@ do_receive(struct ssh_channel *c,
} }
} }
/* We may send more data */
static void
do_send_adjust(struct ssh_channel *s,
UINT32 i)
{
CAST(proxy_channel, self, s);
FLOW_CONTROL_REPORT(&self->chain->super.super, i);
}
static void static void
do_eof(struct ssh_channel *c) do_eof(struct ssh_channel *c)
{ {
...@@ -73,14 +112,18 @@ do_close(struct ssh_channel *c) ...@@ -73,14 +112,18 @@ do_close(struct ssh_channel *c)
static void static void
do_init_io(struct proxy_channel *self) do_init_io(struct proxy_channel *self)
{ {
/* self->super.send = do_send; */ self->super.send_adjust = do_send_adjust;
self->super.receive = do_receive; self->super.receive = do_receive;
self->super.eof = do_eof; self->super.eof = do_eof;
self->super.close = do_close; self->super.close = do_close;
} }
/* NOTE: It seems most calls doesn't provide the correct value for
* rec_max_packet. In these cases, it should probably be filled in
* later, by do_proxy_channel_open_continuation() fill it in later. */
struct proxy_channel * struct proxy_channel *
make_proxy_channel(UINT32 window_size, make_proxy_channel(UINT32 window_size,
UINT32 rec_max_packet,
struct alist *request_types, struct alist *request_types,
int client_side) int client_side)
{ {
...@@ -89,7 +132,7 @@ make_proxy_channel(UINT32 window_size, ...@@ -89,7 +132,7 @@ make_proxy_channel(UINT32 window_size,
self->super.max_window = SSH_MAX_PACKET << 3; self->super.max_window = SSH_MAX_PACKET << 3;
self->super.rec_window_size = window_size; self->super.rec_window_size = window_size;
self->super.rec_max_packet = SSH_MAX_PACKET; self->super.rec_max_packet = rec_max_packet;
self->super.request_types = request_types; self->super.request_types = request_types;
self->init_io = do_init_io; self->init_io = do_init_io;
...@@ -112,8 +155,7 @@ make_proxy_channel(UINT32 window_size, ...@@ -112,8 +155,7 @@ make_proxy_channel(UINT32 window_size,
static struct lsh_string * static struct lsh_string *
do_format_channel_general(struct channel_request_command *s, do_format_channel_general(struct channel_request_command *s,
struct ssh_channel *ch UNUSED, struct ssh_channel *ch UNUSED,
struct command_continuation **c UNUSED struct command_continuation **c UNUSED)
/* , struct exception_handler **e UNUSED */)
{ {
CAST(general_channel_request_command, self, s); CAST(general_channel_request_command, self, s);
...@@ -169,8 +211,7 @@ struct channel_request proxy_channel_request = ...@@ -169,8 +211,7 @@ struct channel_request proxy_channel_request =
static struct lsh_string * static struct lsh_string *
do_format_general_global_request(struct global_request_command *s, do_format_general_global_request(struct global_request_command *s,
struct ssh_connection *connection UNUSED, struct ssh_connection *connection UNUSED,
struct command_continuation **c UNUSED struct command_continuation **c UNUSED)
/* , struct exception_handler **e UNUSED */)
{ {
CAST(general_global_request_command, self, s); CAST(general_global_request_command, self, s);
...@@ -237,6 +278,11 @@ do_proxy_channel_open_continuation(struct command_continuation *c, ...@@ -237,6 +278,11 @@ do_proxy_channel_open_continuation(struct command_continuation *c,
self->channel->chain = chain_channel; self->channel->chain = chain_channel;
chain_channel->chain = self->channel; chain_channel->chain = self->channel;
/* FIXME: I think this is the right thing to do, but I'm not quite
* sure. /nisse */
/* self->channel->rec_max_packet = chain_channel->send_max_packet; */
PROXY_CHANNEL_INIT_IO(self->channel); PROXY_CHANNEL_INIT_IO(self->channel);
PROXY_CHANNEL_INIT_IO(chain_channel); PROXY_CHANNEL_INIT_IO(chain_channel);
...@@ -263,6 +309,7 @@ make_proxy_channel_open_continuation(struct command_continuation *up, ...@@ -263,6 +309,7 @@ make_proxy_channel_open_continuation(struct command_continuation *up,
(vars (vars
; channel type ; channel type
(type . UINT32) (type . UINT32)
(max_packet . UINT32)
(requests object alist) (requests object alist)
(open_request string))) (open_request string)))
*/ */
...@@ -275,7 +322,9 @@ do_proxy_channel_open(struct channel_open_command *c, ...@@ -275,7 +322,9 @@ do_proxy_channel_open(struct channel_open_command *c,
{ {
CAST(proxy_channel_open_command, closure, c); CAST(proxy_channel_open_command, closure, c);
struct proxy_channel *client = make_proxy_channel(WINDOW_SIZE, closure->requests, 1); struct proxy_channel *client
= make_proxy_channel(WINDOW_SIZE, closure->max_packet,
closure->requests, 1);
client->super.write = connection->write; client->super.write = connection->write;
...@@ -291,6 +340,7 @@ do_proxy_channel_open(struct channel_open_command *c, ...@@ -291,6 +340,7 @@ do_proxy_channel_open(struct channel_open_command *c,
struct command * struct command *
make_proxy_channel_open_command(UINT32 type, make_proxy_channel_open_command(UINT32 type,
UINT32 max_packet,
struct lsh_string *open_request, struct lsh_string *open_request,
struct alist *requests) struct alist *requests)
{ {
...@@ -299,7 +349,9 @@ make_proxy_channel_open_command(UINT32 type, ...@@ -299,7 +349,9 @@ make_proxy_channel_open_command(UINT32 type,
self->super.new_channel = do_proxy_channel_open; self->super.new_channel = do_proxy_channel_open;
self->super.super.call = do_channel_open_command; self->super.super.call = do_channel_open_command;
self->type = type; self->type = type;
self->open_request = open_request; self->max_packet = max_packet;
self->requests = requests; self->requests = requests;
self->open_request = open_request;
return &self->super.super; return &self->super.super;
} }
...@@ -43,11 +43,13 @@ ...@@ -43,11 +43,13 @@
struct proxy_channel * struct proxy_channel *
make_proxy_channel(UINT32 window_size, make_proxy_channel(UINT32 window_size,
UINT32 rec_max_packet,
struct alist *request_types, struct alist *request_types,
int client_side); int client_side);
struct command * struct command *
make_proxy_channel_open_command(UINT32 type, make_proxy_channel_open_command(UINT32 type,
UINT32 max_packet,
struct lsh_string *open_request, struct lsh_string *open_request,
struct alist *requests); struct alist *requests);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "proxy_session.c.x" #include "proxy_session.c.x"
#define WINDOW_SIZE (SSH_MAX_PACKET << 3) #define WINDOW_SIZE 10000
/* GABA: /* GABA:
...@@ -51,6 +51,7 @@ static void ...@@ -51,6 +51,7 @@ static void
do_proxy_open_session(struct channel_open *s, do_proxy_open_session(struct channel_open *s,
struct ssh_connection *connection, struct ssh_connection *connection,
UINT32 type, UINT32 type,
UINT32 send_max_packet,
struct simple_buffer *args, struct simple_buffer *args,
struct command_continuation *c, struct command_continuation *c,
struct exception_handler *e) struct exception_handler *e)
...@@ -61,9 +62,18 @@ do_proxy_open_session(struct channel_open *s, ...@@ -61,9 +62,18 @@ do_proxy_open_session(struct channel_open *s,
if (parse_eod(args)) if (parse_eod(args))
{ {
struct proxy_channel *server = make_proxy_channel(WINDOW_SIZE, closure->server_requests, 0); struct proxy_channel *server
= make_proxy_channel(WINDOW_SIZE,
/* FIXME: We should adapt to the other
* end's max packet size. Parhaps should
* be done by
* do_proxy_channel_open_continuation() ?
* */
SSH_MAX_PACKET,
closure->server_requests, 0);
struct command *o = struct command *o =
make_proxy_channel_open_command(type, ssh_format(""), closure->client_requests); make_proxy_channel_open_command(type, send_max_packet,
ssh_format(""), closure->client_requests);
COMMAND_CALL(o, COMMAND_CALL(o,
connection->chain, connection->chain,
......
...@@ -29,12 +29,13 @@ ...@@ -29,12 +29,13 @@
#include "channel_commands.h" #include "channel_commands.h"
#include "format.h" #include "format.h"
#define WINDOW_SIZE (SSH_MAX_PACKET << 3) #define WINDOW_SIZE 10000
static void static void
do_proxy_open_direct_tcpip(struct channel_open *s UNUSED, do_proxy_open_direct_tcpip(struct channel_open *s UNUSED,
struct ssh_connection *connection, struct ssh_connection *connection,
UINT32 type, UINT32 type,
UINT32 send_max_packet,
struct simple_buffer *args, struct simple_buffer *args,
struct command_continuation *c, struct command_continuation *c,
struct exception_handler *e) struct exception_handler *e)
...@@ -50,12 +51,21 @@ do_proxy_open_direct_tcpip(struct channel_open *s UNUSED, ...@@ -50,12 +51,21 @@ do_proxy_open_direct_tcpip(struct channel_open *s UNUSED,
parse_uint32(args, &orig_port) && parse_uint32(args, &orig_port) &&
parse_eod(args)) parse_eod(args))
{ {
struct proxy_channel *server = make_proxy_channel(WINDOW_SIZE, NULL, 0); struct proxy_channel *server
struct command *o = = make_proxy_channel(WINDOW_SIZE,
make_proxy_channel_open_command(type, /* FIXME: We should adapt to the other
ssh_format("%S%i%S%i", * end's max packet size. Parhaps should
host, port, * be done by
orig_host, orig_port), NULL); * do_proxy_channel_open_continuation() ?
* */
SSH_MAX_PACKET,
NULL, 0);
struct command *o
= make_proxy_channel_open_command(type,
send_max_packet,
ssh_format("%S%i%S%i",
host, port,
orig_host, orig_port), NULL);
werror("direct-tcpip open request: host to connect=%S:%i, originator=%S:%i", host, port, orig_host, orig_port); werror("direct-tcpip open request: host to connect=%S:%i, originator=%S:%i", host, port, orig_host, orig_port);
COMMAND_CALL(o, COMMAND_CALL(o,
...@@ -85,6 +95,7 @@ static void ...@@ -85,6 +95,7 @@ static void
do_proxy_open_forwarded_tcpip(struct channel_open *s UNUSED, do_proxy_open_forwarded_tcpip(struct channel_open *s UNUSED,
struct ssh_connection *connection, struct ssh_connection *connection,
UINT32 type, UINT32 type,
UINT32 send_max_packet,
struct simple_buffer *args, struct simple_buffer *args,
struct command_continuation *c, struct command_continuation *c,
struct exception_handler *e) struct exception_handler *e)
...@@ -100,12 +111,21 @@ do_proxy_open_forwarded_tcpip(struct channel_open *s UNUSED, ...@@ -100,12 +111,21 @@ do_proxy_open_forwarded_tcpip(struct channel_open *s UNUSED,
parse_uint32(args, &orig_port) && parse_uint32(args, &orig_port) &&
parse_eod(args)) parse_eod(args))
{ {
struct proxy_channel *server = make_proxy_channel(WINDOW_SIZE, NULL, 0); struct proxy_channel *server
struct command *o = = make_proxy_channel(WINDOW_SIZE,
make_proxy_channel_open_command(type, /* FIXME: We should adapt to the other
ssh_format("%S%i%S%i", * end's max packet size. Parhaps should
host, port, * be done by
orig_host, orig_port), NULL); * do_proxy_channel_open_continuation() ?
* */
SSH_MAX_PACKET,
NULL, 0);
struct command *o
= make_proxy_channel_open_command(type,
send_max_packet,
ssh_format("%S%i%S%i",
host, port,
orig_host, orig_port), NULL);
werror("direct-tcpip open request: address where connection was accepted=%S:%i, originator=%S:%i", host, port, orig_host, orig_port); werror("direct-tcpip open request: address where connection was accepted=%S:%i, originator=%S:%i", host, port, orig_host, orig_port);
COMMAND_CALL(o, COMMAND_CALL(o,
......
...@@ -103,8 +103,10 @@ do_forward_success(struct packet_handler *c, ...@@ -103,8 +103,10 @@ do_forward_success(struct packet_handler *c,
&& (msg_number == SSH_MSG_USERAUTH_SUCCESS) && (msg_number == SSH_MSG_USERAUTH_SUCCESS)
&& parse_eod(&buffer)) && parse_eod(&buffer))
{ {
struct lsh_string *name = self->name;
self->name = NULL;
C_WRITE(connection->chain, packet); C_WRITE(connection->chain, packet);
COMMAND_RETURN(self->c, make_proxy_user(self->name)); COMMAND_RETURN(self->c, make_proxy_user(name));
} }
else else
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment