Commit 53c579d8 authored by Niels Möller's avatar Niels Möller
Browse files

Some bugfixes. Still doesn't work.

Rev: src/client.c:1.26
Rev: src/client.h:1.11
parent 405929a8
...@@ -23,20 +23,24 @@ ...@@ -23,20 +23,24 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* FIXME: Why include stdio? */
#include <stdio.h> #include <stdio.h>
#include "client.h" #include "client.h"
#include "abstract_io.h" #include "abstract_io.h"
#include "channel.h"
#include "connection.h" #include "connection.h"
#include "crypto.h" #include "crypto.h"
#include "debug.h" #include "debug.h"
#include "encrypt.h" #include "encrypt.h"
#include "format.h" #include "format.h"
#include "pad.h" #include "pad.h"
#include "parse.h"
#include "read_line.h" #include "read_line.h"
#include "read_packet.h" #include "read_packet.h"
#include "service.h" #include "service.h"
#include "ssh.h"
#include "unpad.h" #include "unpad.h"
#include "version.h" #include "version.h"
#include "werror.h" #include "werror.h"
...@@ -250,6 +254,15 @@ static int do_accept_service(struct packet_handler *c, ...@@ -250,6 +254,15 @@ static int do_accept_service(struct packet_handler *c,
return LSH_FAIL | LSH_DIE; return LSH_FAIL | LSH_DIE;
} }
struct service_request
{
struct ssh_service super;
int service_name;
struct ssh_service *service;
};
/* FIXME: This should be a packet handler */
struct ssh_service *make_accept_service_handler(int service_name, struct ssh_service *make_accept_service_handler(int service_name,
struct ssh_service *service) struct ssh_service *service)
{ {
...@@ -263,25 +276,16 @@ struct ssh_service *make_accept_service_handler(int service_name, ...@@ -263,25 +276,16 @@ struct ssh_service *make_accept_service_handler(int service_name,
return &closure->super; return &closure->super;
} }
struct service_request
{
struct ssh_service super;
int service_name;
struct ssh_service *service;
};
static int do_request_service(struct ssh_service *c, static int do_request_service(struct ssh_service *c,
struct ssh_connection *connection) struct ssh_connection *connection)
{ {
struct service_request *closure = (struct service_request *) c; struct service_request *closure = (struct service_request *) c;
int res;
MDEBUG(c); MDEBUG(c);
connection->dispatch[SSH_MSG_SERVICE_ACCEPT] = make_accept_service(...); connection->dispatch[SSH_MSG_SERVICE_ACCEPT] = make_accept_service_handler(...);
return A_WRITE(connection->write, format_service_request(closure->name)); return A_WRITE(connection->write, format_service_request(closure->service_name));
} }
struct ssh_service *request_service(int service_name, struct ssh_service *request_service(int service_name,
...@@ -299,7 +303,7 @@ struct ssh_service *request_service(int service_name, ...@@ -299,7 +303,7 @@ struct ssh_service *request_service(int service_name,
struct session struct session
{ {
struct channel super; struct ssh_channel super;
int expect_close; int expect_close;
...@@ -307,9 +311,9 @@ struct session ...@@ -307,9 +311,9 @@ struct session
UINT32 max_window; UINT32 max_window;
/* To access stdio */ /* To access stdio */
struct io_fd *stdin; struct io_fd *in;
struct write_buffer *stdout; struct abstract_write *out;
struct write_buffer *stderr; struct abstract_write *err;
}; };
static int client_session_die(struct ssh_channel *c, struct abstract_write *write) static int client_session_die(struct ssh_channel *c, struct abstract_write *write)
...@@ -326,7 +330,7 @@ static int client_session_die(struct ssh_channel *c, struct abstract_write *writ ...@@ -326,7 +330,7 @@ static int client_session_die(struct ssh_channel *c, struct abstract_write *writ
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
static int do_recieve(struct ssh_channel *self, struct abstract_write *write, static int do_recieve(struct ssh_channel *c, struct abstract_write *write,
int type, struct lsh_string *data) int type, struct lsh_string *data)
{ {
struct session *closure = (struct session *) c; struct session *closure = (struct session *) c;
...@@ -337,7 +341,8 @@ static int do_recieve(struct ssh_channel *self, struct abstract_write *write, ...@@ -337,7 +341,8 @@ static int do_recieve(struct ssh_channel *self, struct abstract_write *write,
if (closure->super.rec_window_size < closure->min_window) if (closure->super.rec_window_size < closure->min_window)
{ {
res = A_WRITE(write, prepare_window_adjust res = A_WRITE(write, prepare_window_adjust
(channel, closure->max_window - closure->super.rec_window_size)); (&closure->super,
closure->max_window - closure->super.rec_window_size));
if (LSH_CLOSEDP(res)) if (LSH_CLOSEDP(res))
return res; return res;
} }
...@@ -345,9 +350,9 @@ static int do_recieve(struct ssh_channel *self, struct abstract_write *write, ...@@ -345,9 +350,9 @@ static int do_recieve(struct ssh_channel *self, struct abstract_write *write,
switch(type) switch(type)
{ {
case CHANNEL_DATA: case CHANNEL_DATA:
return A_WRITE(closure->stdout, data); return A_WRITE(closure->out, data);
case CHANNEL_STDERR_DATA: case CHANNEL_STDERR_DATA:
return A_WRITE(closure->stderr, data); return A_WRITE(closure->err, data);
default: default:
fatal("Internal error!\n"); fatal("Internal error!\n");
} }
...@@ -360,7 +365,7 @@ static int do_start_session(struct ssh_channel *c, struct abstract_write *write) ...@@ -360,7 +365,7 @@ static int do_start_session(struct ssh_channel *c, struct abstract_write *write)
MDEBUG(closure); MDEBUG(closure);
closure->recieve = do_recieve; closure->super.recieve = do_recieve;
} }
/* We have opened a channel of type "session" */ /* We have opened a channel of type "session" */
...@@ -387,7 +392,7 @@ struct client_startup ...@@ -387,7 +392,7 @@ struct client_startup
int shell; int shell;
}; };
void int do_client_startup(struct connection_startup *c, static int do_client_startup(struct connection_startup *c,
struct channel_table *table, struct channel_table *table,
struct abstract_write *write) struct abstract_write *write)
{ {
...@@ -401,11 +406,12 @@ void int do_client_startup(struct connection_startup *c, ...@@ -401,11 +406,12 @@ void int do_client_startup(struct connection_startup *c,
/* Request opening a session. */ /* Request opening a session. */
struct connection_startup *make_client_startup(int want_shell) struct connection_startup *make_client_startup(int want_shell)
{ {
struct ssh_service *closure; struct client_startup *closure;
NEW(closure); NEW(closure);
closure->super.start = do_client_startup; closure->super.start = do_client_startup;
closure->shell = want_shell; closure->shell = want_shell;
return &closure->super; return &closure->super;
} }
...@@ -39,5 +39,13 @@ make_client_callback(struct io_backend *b, ...@@ -39,5 +39,13 @@ make_client_callback(struct io_backend *b,
struct read_handler *make_client_read_line(struct ssh_connection *c); struct read_handler *make_client_read_line(struct ssh_connection *c);
struct close_callback *make_client_close_handler(void); struct close_callback *make_client_close_handler(void);
struct ssh_service *make_accept_service_handler(int service_name,
struct ssh_service *service);
struct ssh_service *request_service(int service_name,
struct ssh_service *service);
struct connection_startup *make_client_startup(int want_shell);
#endif /* LSH_CLIENT_H_INCLUDED */ #endif /* LSH_CLIENT_H_INCLUDED */
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