Commit a55f6f23 authored by Niels Möller's avatar Niels Möller

*** empty log message ***

Rev: src/charset.c:1.3
Rev: src/client.h:1.13
Rev: src/io.h:1.16
Rev: src/parse.c:1.18
Rev: src/read_data.c:1.11
Rev: src/server.c:1.19
Rev: src/server_userauth.c:1.5
Rev: src/service.c:1.8
Rev: src/userauth.h:1.6
parent b8ea5b37
......@@ -167,7 +167,7 @@ struct lsh_string *utf8_to_local(struct lsh_string *s, int free)
switch(parse_utf8(&buffer, &ucs4))
{
case -1:
assert(i<res->length);
assert(i<=res->length);
res->length = i;
if (free)
......
......@@ -47,8 +47,8 @@ struct ssh_service *request_service(int service_name,
struct ssh_service *service);
struct connection_startup *make_client_startup(struct io_fd *in,
struct abstract_write *out,
struct abstract_write *err,
struct io_fd *out,
struct io_fd *err,
int final_request,
struct lsh_string *args);
......
......@@ -64,9 +64,17 @@ struct fd_callback
/* Close callbacks are called with a reason as argument. */
/* End of file while reading */
#define CLOSE_EOF 1
#define CLOSE_WRITE_FAILED 2
#define CLOSE_PROTOCOL_FAILURE 3
/* EPIPE when writing */
#define CLOSE_BROKEN_PIPE 2
#define CLOSE_WRITE_FAILED 3
/* #define CLOSE_READ_FAILED 4 */
#define CLOSE_PROTOCOL_FAILURE 5
struct close_callback
{
......
......@@ -126,6 +126,7 @@ int parse_utf8(struct simple_buffer *buffer, UINT32 *result)
if (first < 0x80)
{
*result = first;
ADVANCE(1);
return 1;
}
......
......@@ -99,6 +99,7 @@ struct read_handler *make_read_data(struct ssh_channel *channel,
NEW(closure);
closure->super.handler = do_read_data;
closure->channel = channel;
closure->write = write;
return &closure->super;
......
......@@ -398,19 +398,34 @@ static int make_pipe(int *fds)
#define REC 0
#define SEND 1
return !socketpair(AF_UNIX, SOCK_STREAM, 0, fds)
&& !shutdown(fds[0], SEND)
&& !shutdown(fds[1], REC);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0)
{
werror("socketpair() failed: %s\n", strerror(errno));
return 0;
}
debug("Created socket pair. Using fd:s %d <-- %d\n", fds[0], fds[1]);
if(shutdown(fds[0], SEND) < 0)
{
werror("shutdown(%d, SEND) failed: %s\n", fds[0], strerror(errno));
return 0;
}
if (shutdown(fds[1], REC) < 0)
{
werror("shutdown(%d, SEND) failed: %s\n", fds[0], strerror(errno));
return 0;
}
return 1;
}
static char *make_env_pair(char *name, struct lsh_string *value)
{
return ssh_format("%z=%lS\0", name, value)->data;
return ssh_format("%z=%lS%c", name, value, 0)->data;
}
static char *make_env_pair_c(char *name, char *value)
{
return ssh_format("%z=%z\0", name, value)->data;
return ssh_format("%z=%z%c", name, value, 0)->data;
}
static int do_spawn_shell(struct channel_request *c,
......@@ -426,7 +441,7 @@ static int do_spawn_shell(struct channel_request *c,
int err[2];
MDEBUG(closure);
MDEBUG(channel);
MDEBUG(session);
if (!parse_eod(args))
return LSH_FAIL | LSH_DIE;
......@@ -539,14 +554,15 @@ static int do_spawn_shell(struct channel_request *c,
/* Close the child's fd:s */
close(in[0]);
close(out[1]);
close(err[2]);
close(err[1]);
session->in
= &io_write(closure->backend, in[1],
SSH_MAX_PACKET,
/* FIXME: Use a proper close callback */
NULL)->buffer->super;
make_channel_close(channel))
->buffer->super;
session->out
= io_read(closure->backend, out[0],
make_channel_read_data(channel),
......@@ -587,7 +603,8 @@ struct channel_request *make_shell_handler(struct io_backend *backend)
NEW(closure);
closure->super.handler = do_spawn_shell;
closure->backend = backend;
return &closure->super;
}
......@@ -18,6 +18,9 @@ struct userauth_service
{
struct ssh_service super;
/* Methods advertised in failure messages */
int *advertised_methods;
struct alist *methods; /* Maps authentication method names to methods */
};
......@@ -137,6 +140,7 @@ static int init_userauth(struct ssh_service *s, /* int name, */
NEW(auth);
auth->super.handler = do_handle_userauth;
auth->advertised_methods = self->advertised_methods;
auth->methods = self->methods;
auth->attempts = AUTH_ATTEMPTS;
......@@ -145,13 +149,15 @@ static int init_userauth(struct ssh_service *s, /* int name, */
return 1;
}
struct ssh_service *make_userauth_service(struct alist *methods)
struct ssh_service *make_userauth_service(int *advertised_methods,
struct alist *methods)
{
struct userauth_service *self;
NEW(self);
self->super.init = init_userauth;
self->advertised_methods = advertised_methods;
self->methods = methods;
return &self->super;
......
......@@ -107,7 +107,7 @@ struct meta_service
};
static int init_meta_service(struct ssh_service *c,
struct ssh_connection *connection)
struct ssh_connection *connection)
{
struct meta_service *closure = (struct meta_service *) c;
......
......@@ -51,7 +51,8 @@ struct lsh_string *format_userauth_failure(int *methods, int partial);
struct lsh_string *format_userauth_success(void);
/* Server functions */
struct ssh_service *make_userauth_service(struct alist *methods);
struct ssh_service *make_userauth_service(int *advertised_methods,
struct alist *methods);
/* Client functions */
struct ssh_service *make_client_userauth(struct lsh_string *username,
......
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