Commit 12fcdd90 authored by Niels Möller's avatar Niels Möller
Browse files

* src/channel.c (register_channel): Deleted connection argument.

* src/channel.h (ssh_channel): Replaced the write pointer with a
pointer to the connection.
(channel_request): Deleted connection argument.
* src/channel.h (CHANNEL_REQUEST): Likewise.

Rev: src/channel.c:1.103
Rev: src/channel.h:1.69
Rev: src/channel_commands.c:1.25
Rev: src/client_pty.c:1.19
Rev: src/gateway_channel.c:1.10
Rev: src/server_session.c:1.66
Rev: src/tcpforward_commands.c:1.35
parent 87c2d355
......@@ -369,12 +369,11 @@ use_channel(struct ssh_connection *connection,
/* FIXME: Delete connection argument */
void
register_channel(struct ssh_connection *connection,
UINT32 local_channel_number,
register_channel(UINT32 local_channel_number,
struct ssh_channel *channel,
int take_into_use)
{
struct channel_table *table = connection->table;
struct channel_table *table = channel->connection->table;
assert(table->in_use[local_channel_number] == CHANNEL_RESERVED);
assert(!table->channels[local_channel_number]);
......@@ -384,17 +383,19 @@ register_channel(struct ssh_connection *connection,
/* NOTE: Is this the right place to install this exception handler? */
channel->e =
make_exc_finish_channel_handler(connection,
make_exc_finish_channel_handler(channel->connection,
local_channel_number,
channel->e ? channel->e : connection->e,
(channel->e ? channel->e
: channel->connection->e),
HANDLER_CONTEXT);
table->channels[local_channel_number] = channel;
if (take_into_use)
use_channel(connection, local_channel_number);
use_channel(channel->connection, local_channel_number);
REMEMBER_RESOURCE(connection->resources, &channel->resources->super);
REMEMBER_RESOURCE(channel->connection->resources,
&channel->resources->super);
}
struct ssh_channel *
......@@ -432,7 +433,7 @@ adjust_rec_window(struct flow_controlled *f, UINT32 written)
* may live longer than the actual channel. */
if (! (channel->flags & (CHANNEL_RECEIVED_EOF | CHANNEL_RECEIVED_CLOSE
| CHANNEL_SENT_CLOSE)))
A_WRITE(channel->write,
C_WRITE(channel->connection,
prepare_window_adjust(channel, written));
}
......@@ -441,7 +442,7 @@ channel_start_receive(struct ssh_channel *channel,
UINT32 initial_window_size)
{
if (channel->rec_window_size < initial_window_size)
A_WRITE(channel->write,
C_WRITE(channel->connection,
prepare_window_adjust
(channel, initial_window_size - channel->rec_window_size));
}
......@@ -874,7 +875,7 @@ DEFINE_PACKET_HANDLER(static, channel_request_handler,
e, HANDLER_CONTEXT);
}
CHANNEL_REQUEST(req, channel, connection, &info, &buffer, c, e);
CHANNEL_REQUEST(req, channel, &info, &buffer, c, e);
}
else
{
......@@ -922,11 +923,10 @@ do_channel_open_continue(struct command_continuation *c,
channel->send_max_packet = self->send_max_packet;
channel->channel_number = self->remote_channel_number;
/* FIXME: Is the channel->write field really needed? */
channel->write = self->connection->write;
register_channel(self->connection,
self->local_channel_number, channel,
channel->connection = self->connection;
register_channel(self->local_channel_number,
channel,
1);
/* FIXME: Doesn't support sending extra arguments with the
......@@ -1679,7 +1679,7 @@ channel_close(struct ssh_channel *channel)
channel->flags |= CHANNEL_SENT_CLOSE;
A_WRITE(channel->write, format_channel_close(channel) );
C_WRITE(channel->connection, format_channel_close(channel) );
if (channel->flags & CHANNEL_RECEIVED_CLOSE)
EXCEPTION_RAISE(channel->e, &finish_exception);
......@@ -1703,7 +1703,7 @@ channel_eof(struct ssh_channel *channel)
verbose("Sending EOF on channel %i\n", channel->channel_number);
channel->flags |= CHANNEL_SENT_EOF;
A_WRITE(channel->write, format_channel_eof(channel) );
C_WRITE(channel->connection, format_channel_eof(channel) );
if ( (channel->flags & CHANNEL_CLOSE_AT_EOF)
&& (channel->flags & (CHANNEL_RECEIVED_EOF | CHANNEL_NO_WAIT_FOR_EOF)) )
......@@ -1718,7 +1718,11 @@ void
init_channel(struct ssh_channel *channel)
{
/* channel->super.handler = do_read_channel; */
#if 0
channel->write = NULL;
#endif
channel->connection = NULL;
channel->super.report = adjust_rec_window;
channel->flags = CHANNEL_CLOSE_AT_EOF;
......@@ -1820,7 +1824,7 @@ do_channel_write(struct abstract_write *w,
channel_eof(closure->channel);
}
else
A_WRITE(closure->channel->write,
C_WRITE(closure->channel->connection,
channel_transmit_data(closure->channel, packet) );
}
......@@ -1838,7 +1842,7 @@ do_channel_write_extended(struct abstract_write *w,
channel_eof(closure->super.channel);
}
else
A_WRITE(closure->super.channel->write,
C_WRITE(closure->super.channel->connection,
channel_transmit_extended(closure->super.channel,
closure->type,
packet));
......
......@@ -119,12 +119,8 @@ struct channel_request_info
(send_window_size . UINT32)
(send_max_packet . UINT32)
; FIXME: Perhaps this should be moved to the channel_table, and
; a pointer to that table be stored here instead?
; Now that we pass the connection pointer to most functions,
; is this field needed at all?
(write object abstract_write)
(connection object ssh_connection)
(request_types object alist)
; If non-NULL, invoked for unknown channel requests.
......@@ -308,16 +304,14 @@ make_channel_open_exception(UINT32 error_code, const char *msg);
(vars
(handler method void
"struct ssh_channel *channel"
;; FIXME: Delete connection argument
"struct ssh_connection *connection"
"struct channel_request_info *info"
"struct simple_buffer *args"
"struct command_continuation *c"
"struct exception_handler *e")))
*/
#define CHANNEL_REQUEST(s, c, conn, i, a, n, e) \
((s)->handler((s), (c), (conn), (i), (a), (n), (e)))
#define CHANNEL_REQUEST(s, c, i, a, n, e) \
((s)->handler((s), (c), (i), (a), (n), (e)))
void init_channel(struct ssh_channel *channel);
......@@ -331,9 +325,7 @@ use_channel(struct ssh_connection *connection,
UINT32 local_channel_number);
void
register_channel(/* FIXME: Delete connection argument */
struct ssh_connection *connection,
UINT32 local_channel_number,
register_channel(UINT32 local_channel_number,
struct ssh_channel *channel,
int take_into_use);
......
......@@ -72,7 +72,7 @@ do_channel_open_command(struct command *s,
* need not pass the connection to NEW_CHANNEL. */
channel->open_continuation = c;
channel->e = e;
register_channel(connection, index, channel, 0);
register_channel(index, channel, 0);
C_WRITE(connection, request);
}
......@@ -94,7 +94,7 @@ do_channel_request_command(struct command *s,
object_queue_add_tail(&channel->pending_requests,
&make_command_context(c, e)->super);
A_WRITE(channel->write, request);
C_WRITE(channel->connection, request);
}
void
......
......@@ -104,7 +104,7 @@ do_client_winch_handler(struct window_change_callback *s,
if (!INTERACT_WINDOW_SIZE(tty, &dims))
return;
A_WRITE(self->channel->write,
C_WRITE(self->channel->connection,
format_window_change(self->channel, &dims));
}
......
......@@ -65,11 +65,11 @@ do_receive(struct ssh_channel *c,
switch(type)
{
case CHANNEL_DATA:
A_WRITE(channel->chain->super.write,
C_WRITE(channel->chain->super.connection,
channel_transmit_data(&channel->chain->super, data));
break;
case CHANNEL_STDERR_DATA:
A_WRITE(channel->chain->super.write,
C_WRITE(channel->chain->super.connection,
channel_transmit_extended(&channel->chain->super, CHANNEL_STDERR_DATA, data));
break;
default:
......@@ -162,7 +162,7 @@ do_gateway_channel_open(struct channel_open_command *c,
target->super.rec_window_size = closure->rec_window_size;
target->super.rec_max_packet = closure->rec_max_packet;
target->super.write = connection->write;
target->super.connection = connection;
*request = format_channel_open_s(closure->type,
local_channel_number,
......@@ -230,7 +230,6 @@ make_general_channel_request_command(struct lsh_string *request)
static void
do_gateway_channel_request(struct channel_request *s UNUSED,
struct ssh_channel *ch,
struct ssh_connection *connection UNUSED,
struct channel_request_info *info,
struct simple_buffer *args,
struct command_continuation *c,
......
......@@ -266,7 +266,7 @@ do_exit_shell(struct exit_callback *c, int signaled,
signaled ? ATOM_EXIT_SIGNAL : ATOM_EXIT_STATUS,
channel->channel_number);
A_WRITE(channel->write,
C_WRITE(channel->connection,
(signaled
? format_exit_signal(channel, core, value)
: format_exit(channel, value)) );
......@@ -603,7 +603,6 @@ spawn_process(struct server_session *session,
static void
do_spawn_shell(struct channel_request *s,
struct ssh_channel *channel,
struct ssh_connection *connection,
struct channel_request_info *info UNUSED,
struct simple_buffer *args,
struct command_continuation *c,
......@@ -625,8 +624,8 @@ do_spawn_shell(struct channel_request *s,
/* Already spawned a shell or command */
goto fail;
switch (spawn_process(session, connection->user,
connection->peer,
switch (spawn_process(session, channel->connection->user,
channel->connection->peer,
closure->backend))
{
case 1: /* Parent */
......@@ -644,7 +643,7 @@ do_spawn_shell(struct channel_request *s,
int env_length = 0;
debug("do_spawn_shell: Child process\n");
assert(getuid() == connection->user->uid);
assert(getuid() == channel->connection->user->uid);
if (session->term)
{
......@@ -656,7 +655,7 @@ do_spawn_shell(struct channel_request *s,
#undef MAX_ENV
#if 1
USER_EXEC(connection->user, 1, argv, env_length, env);
USER_EXEC(channel->connection->user, 1, argv, env_length, env);
/* exec failed! */
verbose("server_session: exec failed (errno = %i): %z\n",
......@@ -700,7 +699,6 @@ make_shell_handler(struct io_backend *backend)
static void
do_spawn_exec(struct channel_request *s,
struct ssh_channel *channel,
struct ssh_connection *connection,
struct channel_request_info *info UNUSED,
struct simple_buffer *args,
struct command_continuation *c,
......@@ -732,8 +730,8 @@ do_spawn_exec(struct channel_request *s,
{
struct lsh_string *command_line = ssh_format("%ls", command_len, command);
switch (spawn_process(session, connection->user,
connection->peer,
switch (spawn_process(session, channel->connection->user,
channel->connection->peer,
closure->backend))
{
case 1: /* Parent */
......@@ -763,7 +761,7 @@ do_spawn_exec(struct channel_request *s,
debug("do_spawn_shell: Child process\n");
assert(getuid() == connection->user->uid);
assert(getuid() == channel->connection->user->uid);
assert(argv[2]);
if (session->term)
......@@ -775,7 +773,7 @@ do_spawn_exec(struct channel_request *s,
assert(env_length <= MAX_ENV);
#undef MAX_ENV
USER_EXEC(connection->user, 0, argv, env_length, env);
USER_EXEC(channel->connection->user, 0, argv, env_length, env);
/* exec failed! */
verbose("server_session: exec failed (errno = %i): %z\n",
......@@ -846,7 +844,6 @@ lookup_subsystem(struct subsystem_request *self,
static void
do_spawn_subsystem(struct channel_request *s,
struct ssh_channel *channel,
struct ssh_connection *connection,
struct channel_request_info *info UNUSED,
struct simple_buffer *args,
struct command_continuation *c,
......@@ -880,8 +877,8 @@ do_spawn_subsystem(struct channel_request *s,
session->pty = NULL;
}
switch (spawn_process(session, connection->user,
connection->peer,
switch (spawn_process(session, channel->connection->user,
channel->connection->peer,
self->super.backend))
{
case 1: /* Parent */
......@@ -897,7 +894,7 @@ do_spawn_subsystem(struct channel_request *s,
debug("do_spawn_subsystem: Child process\n");
USER_EXEC(connection->user, 1, argv, 0, NULL);
USER_EXEC(channel->connection->user, 1, argv, 0, NULL);
werror("server_session: subsystem exec failed (errno = %i): %z\n",
errno, STRERROR(errno));
......@@ -933,7 +930,6 @@ make_subsystem_handler(struct io_backend *backend,
static void
do_alloc_pty(struct channel_request *c UNUSED,
struct ssh_channel *channel,
struct ssh_connection *connection,
struct channel_request_info *info UNUSED,
struct simple_buffer *args,
struct command_continuation *s,
......@@ -969,7 +965,7 @@ do_alloc_pty(struct channel_request *c UNUSED,
{
struct pty_info *pty = make_pty_info();
if (pty_allocate(pty, connection->user->uid))
if (pty_allocate(pty, channel->connection->user->uid))
{
struct termios ios;
......@@ -1025,7 +1021,6 @@ pty_request_handler =
static void
do_window_change_request(struct channel_request *c UNUSED,
struct ssh_channel *channel,
struct ssh_connection *connection UNUSED,
struct channel_request_info *info UNUSED,
struct simple_buffer *args,
struct command_continuation *s,
......
......@@ -160,7 +160,7 @@ new_tcpip_channel(struct channel_open_command *c,
debug("tcpforward_commands.c: new_tcpip_channel\n");
channel = &make_channel_forward(self->peer->fd, TCPIP_WINDOW_SIZE)->super;
channel->write = connection->write;
channel->connection = connection;
*request = format_channel_open(self->type, local_channel_number,
channel,
......
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