Commit 656da460 authored by Niels Möller's avatar Niels Möller
Browse files

* (practically every file): Adapted to new gc and object system.

Rev: ChangeLog:1.2
Rev: doc/TODO:1.11
Rev: src/Makefile.am.in:1.6
Rev: src/abstract_crypto.h:1.14
Rev: src/abstract_io.h:1.19
Rev: src/alist.c:1.12
Rev: src/alist.h:1.7
Rev: src/blocking_write.c:1.7
Rev: src/channel.c:1.14
Rev: src/channel.h:1.17
Rev: src/client.c:1.36
Rev: src/client_keyexchange.c:1.17
Rev: src/client_keyexchange.h:1.9
Rev: src/client_userauth.c:1.5
Rev: src/connection.c:1.18
Rev: src/crypto.c:1.13
Rev: src/debug.c:1.16
Rev: src/disconnect.c:1.8
Rev: src/encrypt.c:1.15
Rev: src/format.c:1.20
Rev: src/format.h:1.15
Rev: src/gc.c:1.2
Rev: src/io.c:1.31
Rev: src/io.h:1.21
Rev: src/keyexchange.c:1.25
Rev: src/keyexchange.h:1.24
Rev: src/list.c:1.2
Rev: src/list.h:1.2
Rev: src/lsh.c:1.24
Rev: src/lshd.c:1.21
Rev: src/make_class:1.6
Rev: src/packet_ignore.c:1.6
Rev: src/pad.c:1.18
Rev: src/parse.c:1.19
Rev: src/parse.h:1.14
Rev: src/password.c:1.1
Rev: src/password.h:1.7
Rev: src/publickey_crypto.c:1.19
Rev: src/publickey_crypto.h:1.12
Rev: src/randomness.c:1.8
Rev: src/randomness.h:1.5
Rev: src/read_data.c:1.13
Rev: src/read_line.c:1.14
Rev: src/read_line.h:1.9
Rev: src/read_packet.c:1.25
Rev: src/reaper.c:1.4
Rev: src/reaper.h:1.3
Rev: src/server.c:1.24
Rev: src/server_keyexchange.c:1.15
Rev: src/server_keyexchange.h:1.6
Rev: src/server_password.c:1.7
Rev: src/server_userauth.c:1.6
Rev: src/session.h:1.10
Rev: src/unpad.c:1.14
Rev: src/userauth.c:1.1
Rev: src/userauth.h:1.7
Rev: src/write_buffer.c:1.12
Rev: src/write_buffer.h:1.11
Rev: src/xalloc.c:1.14
Rev: src/xalloc.h:1.14
Rev: src/zlib.c:1.9
parent 9efec583
Fri Dec 4 02:30:28 1998 <nisse@puck>
* (practically every file): Adapted to new gc and object system.
* xalloc.c (lsh_object_check_subtype): Allow NULL pointers. They
are occasionally permissible (for instance, the NULL crypto
algorithm), and when they aren't the error will be detected early
anyway.
(lsh_object_check): -"-
* keyexchange.c (do_handle_kexinit): Use an object_list for
passing around the selected algorithms. The void ** that was used
earlier was unfriendly to the gc.
Sun Nov 22 00:57:16 1998 <nisse@puck>
* lsh.c (main): Bug fix (pass *address* of crypto_rc4_algorithm).
......
......@@ -61,6 +61,8 @@ lssh_space_alloc.
Make lists of integers (usually atoms) its own type. Can this be done
in such a way that they can also be allocated statically?
Have the allocator initialize all objects automatically.
CHANNELS
......
......@@ -31,13 +31,13 @@ bin_PROGRAMS = lsh lshd
generated_sources = atoms_defines.h atoms_gperf.c atoms_table.c
common_sources = abstract_io.c alist.c atoms.c bignum.c channel.c \
charset.c connection.c crypto.c \
debug.c disconnect.c encrypt.c format.c getopt.c io.c keyexchange.c \
packet_ignore.c pad.c parse.c publickey_crypto.c \
common_sources = abstract_io.c abstract_crypto.c alist.c atoms.c \
bignum.c channel.c charset.c connection.c crypto.c \
debug.c disconnect.c encrypt.c format.c gc.c getopt.c io.c keyexchange.c \
list.c packet_ignore.c pad.c parse.c password.c publickey_crypto.c \
randomness.c \
read_data.c read_line.c read_packet.c service.c \
translate_signal.c unpad.c \
translate_signal.c unpad.c userauth.c \
werror.c write_buffer.c xalloc.c
lsh_SOURCES = $(common_sources) lsh.c client.c client_keyexchange.c \
......
......@@ -28,6 +28,12 @@
#include "lsh_types.h"
/* Use the same instance struct for both hash functions and macs. This
* is a little ugly. */
#define mac_instance_class hash_instance_class
#define mac_instance hash_instance
#define mac_size hash_size
#define CLASS_DECLARE
#include "abstract_crypto.h.x"
#undef CLASS_DECLARE
......@@ -65,7 +71,7 @@ struct crypto_instance
(block_size simple UINT32)
(key_size simple UINT32)
(make_crypt method (object crypto_instance)
"int mode" "UIINT8 *key")))
"int mode" "UINT8 *key")))
*/
#if 0
......@@ -87,6 +93,8 @@ struct crypto_algorithm
#define MAKE_DECRYPT(crypto, key) \
((crypto)->make_crypt((crypto), CRYPTO_DECRYPT, (key)))
/* FIXME: Hashes could use non-virtual methods. */
/* CLASS:
(class
(name hash_instance)
......@@ -120,10 +128,6 @@ struct hash_instance
#define HASH_COPY(instance) ((instance)->copy((instance)))
/* Used for both hash functions ad macs */
#define mac_instance hash_instance
#define mac_size hash_size
/* CLASS:
(class
(name hash_algorithm)
......
......@@ -46,7 +46,7 @@
(class
(name abstract_read)
(vars
(read method int
(read indirect-method int
"UINT32 length" "UINT8 *buffer")))
*/
#if 0
......@@ -67,7 +67,7 @@ struct abstract_read
(class
(name read_handler)
(vars
(handler method int "struct abstract_read *read")))
(handler indirect-method int "struct abstract_read *read")))
*/
#if 0
......
......@@ -33,6 +33,10 @@
#include "werror.h"
#include "xalloc.h"
#define CLASS_DEFINE
#include "alist.h.x"
#undef CLASS_DEFINE
struct alist_node
{
struct alist_node *next;
......
......@@ -28,6 +28,13 @@
#include "lsh_types.h"
/* Forward declaration */
struct alist;
#define CLASS_DECLARE
#include "alist.h.x"
#undef CLASS_DECLARE
/* Not supported anymore */
/* #define ALIST_USE_SIZE 0 */
......@@ -88,6 +95,4 @@ struct alist *make_linked_alist(int n, ...);
#define make_alist make_linear_alist
#include "alist.h.x"
#endif /* LSH_ALIST_H_INCLUDED */
......@@ -11,13 +11,11 @@
static int do_write(struct abstract_write *w,
struct lsh_string *packet)
{
struct packet_blocking_write *closure
= (struct packet_blocking_write *) w;
CAST(packet_blocking_write, closure, w);
UINT32 left = packet->length;
UINT8 *p = packet->data;
MDEBUG(closure);
while(left)
{
int written = write(closure->fd, p, left);
......
......@@ -38,6 +38,25 @@
#include "channel.h.x"
#undef CLASS_DEFINE
#include "channel.c.x"
/* CLASS:
(class
(name connection_service)
(super ssh_service)
(vars
; Supported global requests
(global_requests object alist)
(channel_types object alist)
; Initialize connection (for instance, request channels to be
; opened or services to be forwarded).
(start object connection_startup)))
*/
#if 0
struct connection_service
{
struct ssh_service super;
......@@ -50,35 +69,57 @@ struct connection_service
* or services to be forwarded. */
struct connection_startup *start;
};
#endif
/* CLASS:
(class
(name channel_handler)
(super packet_handler)
(vars
(table object channel_table)))
*/
#if 0
struct channel_handler
{
struct packet_handler super;
struct channel_table *table;
};
#endif
/* CLASS:
(class
(name global_request_handler)
(super channel_handler super)
(vars
(global_requests object alist)))
*/
#if 0
struct global_request_handler
{
struct channel_handler super;
struct alist *global_requests;
};
#endif
/* CLASS:
(class
(name channel_open_handler)
(super channel_handler)
(vars
(channel_types object alist)))
*/
#if 0
struct channel_open_handler
{
struct channel_handler super;
struct alist *channel_types;
};
#if 0
struct channel_request_handler
{
struct channel_handler *super;
struct alist *request_types;
};
#endif
struct lsh_string *format_global_failure(void)
......@@ -152,9 +193,8 @@ struct lsh_string *prepare_window_adjust(struct ssh_channel *channel,
struct channel_table *make_channel_table(void)
{
struct channel_table *table;
NEW(channel_table, table);
NEW(table);
table->channels = lsh_space_alloc(sizeof(struct ssh_channel *)
* INITIAL_CHANNELS);
table->allocated_channels = INITIAL_CHANNELS;
......@@ -256,15 +296,13 @@ static int do_global_request(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct global_request_handler *closure = (struct global_request_handler *) c;
CAST(global_request_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
int name;
int want_reply;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -291,7 +329,7 @@ static int do_channel_open(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_open_handler *closure = (struct channel_open_handler *) c;
CAST(channel_open_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
......@@ -300,8 +338,6 @@ static int do_channel_open(struct packet_handler *c,
UINT32 window_size;
UINT32 max_packet;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -379,7 +415,7 @@ static int do_channel_request(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
......@@ -387,8 +423,6 @@ static int do_channel_request(struct packet_handler *c,
int type;
int want_reply;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -431,15 +465,13 @@ static int do_window_adjust(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
UINT32 size;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -481,15 +513,13 @@ static int do_channel_data(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
struct lsh_string *data;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -554,7 +584,7 @@ static int do_channel_extended_data(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
......@@ -562,8 +592,6 @@ static int do_channel_extended_data(struct packet_handler *c,
UINT32 type;
struct lsh_string *data;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -638,14 +666,12 @@ static int do_channel_eof(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -700,14 +726,12 @@ static int do_channel_close(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -758,7 +782,7 @@ static int do_channel_open_confirm(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
......@@ -767,8 +791,6 @@ static int do_channel_open_confirm(struct packet_handler *c,
UINT32 window_size;
UINT32 max_packet;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -805,7 +827,7 @@ static int do_channel_open_failure(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
......@@ -818,8 +840,6 @@ static int do_channel_open_failure(struct packet_handler *c,
UINT8 *language;
UINT32 language_length;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -858,14 +878,12 @@ static int do_channel_success(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -890,14 +908,12 @@ static int do_channel_failure(struct packet_handler *c,
struct ssh_connection *connection,
struct lsh_string *packet)
{
struct channel_handler *closure = (struct channel_handler *) c;
CAST(channel_handler, closure, c);
struct simple_buffer buffer;
int msg_number;
UINT32 channel_number;
MDEBUG(closure);
simple_buffer_init(&buffer, packet->length, packet->data);
if (parse_uint8(&buffer, &msg_number)
......@@ -921,88 +937,75 @@ static int do_channel_failure(struct packet_handler *c,
static int init_connection_service(struct ssh_service *s,
struct ssh_connection *connection)
{
struct connection_service *self = (struct connection_service *) s;
CAST(connection_service, self, s);
struct channel_table *table;
struct global_request_handler *globals;
struct channel_open_handler *open;
struct channel_handler *request;
struct channel_handler *adjust;
struct channel_handler *data;
struct channel_handler *extended;
NEW(global_request_handler, globals);
NEW(channel_open_handler, open);
NEW(channel_handler, request);
struct channel_handler *eof;
struct channel_handler *close;
NEW(channel_handler, adjust);
NEW(channel_handler, data);
NEW(channel_handler, extended);
struct channel_handler *open_confirm;
struct channel_handler *open_failure;
NEW(channel_handler, eof);
NEW(channel_handler, close);
struct channel_handler *channel_success;
struct channel_handler *channel_failure;
NEW(channel_handler, open_confirm);
NEW(channel_handler, open_failure);
MDEBUG(self);
NEW(channel_handler, channel_success);
NEW(channel_handler, channel_failure);
table = make_channel_table();
NEW(globals);
globals->super.super.handler = do_global_request;
globals->super.table = table;
globals->global_requests = self->global_requests;
connection->dispatch[SSH_MSG_GLOBAL_REQUEST] = &globals->super.super;
NEW(open);
open->super.super.handler = do_channel_open;
open->super.table = table;
open->channel_types = self->channel_types;
connection->dispatch[SSH_MSG_CHANNEL_OPEN] = &open->super.super;
NEW(request);
request->super.handler = do_channel_request;
request->table = table;
connection->dispatch[SSH_MSG_CHANNEL_REQUEST] = &request->super;
NEW(adjust);
adjust->super.handler = do_window_adjust;
adjust->table = table;
connection->dispatch[SSH_MSG_CHANNEL_WINDOW_ADJUST] = &adjust->super;
NEW(data);
data->super.handler = do_channel_data;
data->table = table;
connection->dispatch[SSH_MSG_CHANNEL_DATA] = &data->super;
NEW(extended);
extended->super.handler = do_channel_extended_data;
extended->table = table;
connection->dispatch[SSH_MSG_CHANNEL_WINDOW_ADJUST] = &extended->super;
NEW(eof);
eof->super.handler = do_channel_eof;
eof->table = table;
connection->dispatch[SSH_MSG_CHANNEL_EOF] = &eof->super;
NEW(close);
close->super.handler = do_channel_close;
close->table = table;
connection->dispatch[SSH_MSG_CHANNEL_CLOSE] = &close->super;
NEW(open_confirm);
open_confirm->super.handler = do_channel_open_confirm;
open_confirm->table = table;
connection->dispatch[SSH_MSG_CHANNEL_OPEN_CONFIRMATION] = &open_confirm->super;
NEW(open_failure);
open_failure->super.handler = do_channel_open_failure;
open_failure->table = table;
connection->dispatch[SSH_MSG_CHANNEL_OPEN_FAILURE] = &open_failure->super;
NEW(channel_success);
channel_success->super.handler = do_channel_success;
channel_success->table = table;
connection->dispatch[SSH_MSG_CHANNEL_SUCCESS] = &channel_success->super;
NEW(channel_failure);
channel_failure->super.handler = do_channel_failure;
channel_failure->table = table;
connection->dispatch[SSH_MSG_CHANNEL_FAILURE] = &channel_failure->super;
......@@ -1016,9 +1019,7 @@ struct ssh_service *make_connection_service(struct alist *global_requests,
struct alist *channel_types,
struct connection_startup *start)
{
struct connection_service *self;
NEW(self);
NEW(connection_service, self);
self->super.init = init_connection_service;
self->global_requests = global_requests;
......@@ -1118,17 +1119,37 @@ struct lsh_string *channel_transmit_extended(struct ssh_channel *channel,
}
/* Writing data to a channel */
/* CLASS:
(class
(name channel_write)
(super abstract_write)
(vars
(channel object ssh_channel)))
*/
#if 0
struct channel_write
{
struct abstract_write super;
struct ssh_channel *channel;
};
#endif
/* CLASS:
(class
(name channel_write_extended)
(super channel_write)
(vars
(type simple UINT32)))
*/
#if 0
struct channel_write_extended
{
struct channel_write super;
UINT32 type;
};
#endif
static int do_channel_write(struct abstract_write *w,
struct lsh_string *packet)
......@@ -1142,7 +1163,7 @@ static int do_channel_write(struct abstract_write *w,
static int do_channel_write_extended(struct abstract_write *w,
struct lsh_string *packet)
{
struct channel_write_extended *closure = (struct channel_write_extended *) w;
CAST(channel_write_extended, closure, w);
return A_WRITE(closure->super.channel->write,
channel_transmit_extended(closure->super.channel,
......@@ -1152,9 +1173,7 @@ static int do_channel_write_extended(struct abstract_write *w,
struct abstract_write *make_channel_write(struct ssh_channel *channel)
{
struct channel_write *closure;
NEW(closure);
NEW(channel_write, closure);
closure->super.write = do_channel_write;
closure->channel = channel;