Commit 79878b37 authored by Niels Möller's avatar Niels Möller
Browse files

* src/sexp_commands.c (make_read_sexp_exception_handler): Added

context argument.
(do_read_sexp): Pass HANDLER_CONTEXT.

* src/sexp.c (lookup_sexp_format): Use strcmp rather than
strcasecmp.
(sexp_input_argp, sexp_output_argp): Split sexp_argp into two
parsers.

* src/server_userauth.c (make_exc_userauth_handler): Added context
argument.
(do_userauth): Pass HANDLER_CONTEXT.

* src/server_session.c (do_spawn_shell): Pass HANDLER_CONTEXT.

Rev: src/read_data.h:1.11
Rev: src/server_session.c:1.19
Rev: src/server_userauth.c:1.20
Rev: src/sexp.c:1.17
Rev: src/sexp.h:1.20
Rev: src/sexp_commands.c:1.3
Rev: src/sexp_streamed_parser.c:1.14
parent 79905f3c
......@@ -31,8 +31,11 @@
struct io_read_callback *make_read_data(struct ssh_channel *channel,
struct abstract_write *write);
#if 0
struct exception_handler *
make_exc_read_eof_channel_handler(struct ssh_channel *channel,
struct exception_handler *e);
struct exception_handler *e,
const char *context);
#endif
#endif /* LSH_READ_DATA_H_INCLUDED */
......@@ -860,7 +860,8 @@ do_spawn_shell(struct channel_request *c,
struct exception_handler *io_exception_handler
= make_channel_io_exception_handler(channel,
"lshd: Child stdio: ",
&default_exception_handler);
&default_exception_handler,
HANDLER_CONTEXT);
/* Close callback for stderr and stdout */
struct close_callback *read_close_callback
......
......@@ -382,11 +382,13 @@ static struct exception_handler *
make_exc_userauth_handler(struct ssh_connection *connection,
struct int_list *advertised_methods,
unsigned attempts,
struct exception_handler *parent)
struct exception_handler *parent,
const char *context)
{
NEW(exc_userauth_handler, self);
self->super.raise = do_exc_userauth_handler;
self->super.parent = parent;
self->super.context = context;
self->connection = connection;
self->advertised_methods = advertised_methods;
......@@ -416,7 +418,8 @@ static void do_userauth(struct command *s,
c, e));
auth->e = make_exc_userauth_handler(connection,
self->advertised_methods,
AUTH_ATTEMPTS, e);
AUTH_ATTEMPTS, e,
HANDLER_CONTEXT);
connection->dispatch[SSH_MSG_USERAUTH_REQUEST] = &auth->super;
}
......
......@@ -749,21 +749,29 @@ static int lookup_sexp_format(const char *name)
for (i = 0; sexp_formats[i].name; i++)
{
if (strcasecmp(sexp_formats[i].name, name) == 0)
if (strcmp(sexp_formats[i].name, name) == 0)
return sexp_formats[i].id;
}
return -1;
}
static const struct argp_option
sexp_options[] =
sexp_input_options[] =
{
#if 0
{ NULL, 0, NULL, 0, "Valid sexp-formats are transport, canonical, "
"advanced and international.", 0 },
{ "input-format", 'i', "format", 0,
"Variant of the s-expression syntax to accept", 0},
#endif
"Variant of the s-expression syntax to accept.", 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static const struct argp_option
sexp_output_options[] =
{
{ NULL, 0, NULL, 0, "Valid sexp-formats are transport, canonical, "
"advanced and international.", 0 },
{ "output-format", 'o', "format", 0,
"Variant of the s-expression syntax to generate", 0},
"Variant of the s-expression syntax to generate.", 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
......@@ -775,23 +783,30 @@ sexp_argp_parser(int key, char *arg, struct argp_state *state)
default:
return ARGP_ERR_UNKNOWN;
case 'o':
case 'i':
{
int format = lookup_sexp_format(arg);
if (format < 0)
argp_error(state, "Unknown s-expression format '%s'", arg);
else
(sexp_argp_input *) (state->input) = format;
*(sexp_argp_state *) (state->input) = format;
break;
}
}
return 0;
}
const struct argp sexp_argp =
const struct argp sexp_input_argp =
{
sexp_input_options,
sexp_argp_parser,
NULL, NULL, NULL, NULL
};
const struct argp sexp_output_argp =
{
sexp_options,
sexp_output_options,
sexp_argp_parser,
"\vValid sexp-formats are transport, canonical, "
"advanced and international.",
NULL, NULL, NULL
NULL, NULL, NULL, NULL
};
......@@ -182,8 +182,9 @@ make_read_sexp(int style, int goon,
struct command_continuation *c,
struct exception_handler *e);
extern const struct argp sexp_argp;
#define sexp_argp_input int
extern const struct argp sexp_input_argp;
extern const struct argp sexp_output_argp;
#define sexp_argp_state int
#endif /* LSH_SEXP_H_INCLUDED */
......
......@@ -148,11 +148,14 @@ do_read_sexp_exception_handler(struct exception_handler *s,
static struct exception_handler *
make_read_sexp_exception_handler(struct io_fd *fd,
struct exception_handler *e)
struct exception_handler *e,
const char *context)
{
NEW(read_sexp_exception_handler, self);
self->super.raise = do_read_sexp_exception_handler;
self->super.parent = e;
self->super.context = context;
self->fd = &fd->super;
return &self->super;
......@@ -174,8 +177,9 @@ do_read_sexp(struct command *s,
io_read(fd,
make_buffered_read(SEXP_BUFFER_SIZE,
make_read_sexp(self->format, self->goon, c,
make_read_sexp_exception_handler(fd, e))),
make_read_sexp(self->format, self->goon, c,
make_read_sexp_exception_handler(fd, e,
HANDLER_CONTEXT))),
NULL);
}
......
......@@ -657,7 +657,8 @@ static UINT32 do_expect_eof(struct read_handler **s,
return 0;
}
static struct read_handler *make_expect_eof(struct exception_handler *e)
static struct read_handler *
make_expect_eof(struct exception_handler *e)
{
NEW(parser, self);
self->super.handler = do_expect_eof;
......
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