Skip to content
Snippets Groups Projects
Commit 25a8dbc1 authored by Pontus Freyhult's avatar Pontus Freyhult
Browse files

(userauth_none): New class.

(do_none_authenticate): Added code for login-auth-mode to
auto login a specific user.
(make_userauth_none): New function.

Rev: src/server_userauth.c:1.39
parent 0cb35838
Branches
Tags
No related merge requests found
...@@ -384,9 +384,18 @@ make_userauth_service(struct int_list *advertised_methods, ...@@ -384,9 +384,18 @@ make_userauth_service(struct int_list *advertised_methods,
} }
/* GABA:
(class
(name userauth_none)
(super userauth)
(vars
(user object lsh_user)
(ignore_username . int)))
*/
/* None service (which works like external-keyexchange) */ /* None service (which works like external-keyexchange) */
static void static void
do_none_authenticate(struct userauth *s UNUSED, do_none_authenticate(struct userauth *s,
struct ssh_connection *connection UNUSED, struct ssh_connection *connection UNUSED,
struct lsh_string *username, struct lsh_string *username,
uint32_t service UNUSED, uint32_t service UNUSED,
...@@ -394,6 +403,9 @@ do_none_authenticate(struct userauth *s UNUSED, ...@@ -394,6 +403,9 @@ do_none_authenticate(struct userauth *s UNUSED,
struct command_continuation *c, struct command_continuation *c,
struct exception_handler *e) struct exception_handler *e)
{ {
CAST(userauth_none, self, s);
trace("do_none_authenticate\n");
username = utf8_to_local(username, 1, 1); username = utf8_to_local(username, 1, 1);
if (!username) if (!username)
{ {
...@@ -407,9 +419,15 @@ do_none_authenticate(struct userauth *s UNUSED, ...@@ -407,9 +419,15 @@ do_none_authenticate(struct userauth *s UNUSED,
= STATIC_EXCEPTION(EXC_USERAUTH, = STATIC_EXCEPTION(EXC_USERAUTH,
"User needs to authenticate properly"); "User needs to authenticate properly");
if (connection->user if (self->ignore_username ||
&& lsh_string_eq(username, connection->user->name)) (connection->user &&
lsh_string_eq(username, connection->user->name)))
{
if (self->ignore_username)
connection->user = self->user;
COMMAND_RETURN(c, connection->user); COMMAND_RETURN(c, connection->user);
}
else else
EXCEPTION_RAISE(e, &wrong_user); EXCEPTION_RAISE(e, &wrong_user);
} }
...@@ -419,5 +437,16 @@ do_none_authenticate(struct userauth *s UNUSED, ...@@ -419,5 +437,16 @@ do_none_authenticate(struct userauth *s UNUSED,
lsh_string_free(username); lsh_string_free(username);
} }
struct userauth server_userauth_none =
{ STATIC_HEADER, do_none_authenticate }; struct userauth *
make_userauth_none(int ignore_username, struct lsh_user *user)
{
NEW(userauth_none, self);
trace("make_userauth_none\n");
self->super.authenticate = do_none_authenticate;
self->ignore_username = ignore_username;
self->user = user;
return &self->super;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment