[auth.h auth2.c]
     move Authmethod definitons to per-method file.

NOTE: The rest of this patch is with the import of the auth2-*.c files.
This commit is contained in:
Ben Lindstrom 2002-06-06 20:52:37 +00:00
parent cec2ea8d02
commit 511bb24c5b
3 changed files with 44 additions and 49 deletions

View File

@ -65,6 +65,9 @@
pass # of socket-fd to ssh-keysign, keysign verfies locally used pass # of socket-fd to ssh-keysign, keysign verfies locally used
ip-address using this socket-fd, restricts fake local hostnames ip-address using this socket-fd, restricts fake local hostnames
to actual local hostnames; ok stevesk@ to actual local hostnames; ok stevesk@
- markus@cvs.openbsd.org 2002/05/31 11:35:15
[auth.h auth2.c]
move Authmethod definitons to per-method file.
20020604 20020604
- (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed - (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed
@ -749,4 +752,4 @@
- (stevesk) entropy.c: typo in debug message - (stevesk) entropy.c: typo in debug message
- (djm) ssh-keygen -i needs seeded RNG; report from markus@ - (djm) ssh-keygen -i needs seeded RNG; report from markus@
$Id: ChangeLog,v 1.2162 2002/06/06 20:51:04 mouring Exp $ $Id: ChangeLog,v 1.2163 2002/06/06 20:52:37 mouring Exp $

16
auth.h
View File

@ -1,4 +1,4 @@
/* $OpenBSD: auth.h,v 1.38 2002/05/25 18:51:07 markus Exp $ */ /* $OpenBSD: auth.h,v 1.39 2002/05/31 11:35:15 markus Exp $ */
/* /*
* Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2000 Markus Friedl. All rights reserved.
@ -43,6 +43,7 @@
#endif #endif
typedef struct Authctxt Authctxt; typedef struct Authctxt Authctxt;
typedef struct Authmethod Authmethod;
typedef struct KbdintDevice KbdintDevice; typedef struct KbdintDevice KbdintDevice;
struct Authctxt { struct Authctxt {
@ -71,6 +72,12 @@ struct Authctxt {
#endif #endif
}; };
struct Authmethod {
char *name;
int (*userauth)(Authctxt *authctxt);
int *enabled;
};
/* /*
* Keyboard interactive device: * Keyboard interactive device:
* init_ctx returns: non NULL upon success * init_ctx returns: non NULL upon success
@ -100,13 +107,6 @@ BIGNUM *auth_rsa_generate_challenge(Key *);
int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]); int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **); int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
/* ssh2 methods */
int userauth_none(Authctxt *);
int userauth_passwd(Authctxt *);
int userauth_pubkey(Authctxt *);
int userauth_hostbased(Authctxt *);
int userauth_kbdint(Authctxt *);
int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *); int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
int user_key_allowed(struct passwd *, Key *); int user_key_allowed(struct passwd *, Key *);

72
auth2.c
View File

@ -23,7 +23,7 @@
*/ */
#include "includes.h" #include "includes.h"
RCSID("$OpenBSD: auth2.c,v 1.92 2002/05/25 18:51:07 markus Exp $"); RCSID("$OpenBSD: auth2.c,v 1.93 2002/05/31 11:35:15 markus Exp $");
#include "ssh2.h" #include "ssh2.h"
#include "xmalloc.h" #include "xmalloc.h"
@ -42,13 +42,22 @@ extern u_char *session_id2;
extern int session_id2_len; extern int session_id2_len;
Authctxt *x_authctxt = NULL; Authctxt *x_authctxt = NULL;
static int one = 1;
typedef struct Authmethod Authmethod; /* methods */
struct Authmethod {
char *name; extern Authmethod method_none;
int (*userauth)(Authctxt *authctxt); extern Authmethod method_pubkey;
int *enabled; extern Authmethod method_passwd;
extern Authmethod method_kbdint;
extern Authmethod method_hostbased;
Authmethod *authmethods[] = {
&method_none,
&method_pubkey,
&method_passwd,
&method_kbdint,
&method_hostbased,
NULL
}; };
/* protocol */ /* protocol */
@ -62,27 +71,6 @@ static char *authmethods_get(void);
int user_key_allowed(struct passwd *, Key *); int user_key_allowed(struct passwd *, Key *);
int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
/* auth */
Authmethod authmethods[] = {
{"none",
userauth_none,
&one},
{"publickey",
userauth_pubkey,
&options.pubkey_authentication},
{"password",
userauth_passwd,
&options.password_authentication},
{"keyboard-interactive",
userauth_kbdint,
&options.kbd_interactive_authentication},
{"hostbased",
userauth_hostbased,
&options.hostbased_authentication},
{NULL, NULL, NULL}
};
/* /*
* loop until authctxt->success == TRUE * loop until authctxt->success == TRUE
*/ */
@ -595,18 +583,20 @@ auth_get_user(void)
static char * static char *
authmethods_get(void) authmethods_get(void)
{ {
Authmethod *method = NULL;
Buffer b; Buffer b;
char *list; char *list;
int i;
buffer_init(&b); buffer_init(&b);
for (method = authmethods; method->name != NULL; method++) { for (i = 0; authmethods[i] != NULL; i++) {
if (strcmp(method->name, "none") == 0) if (strcmp(authmethods[i]->name, "none") == 0)
continue; continue;
if (method->enabled != NULL && *(method->enabled) != 0) { if (authmethods[i]->enabled != NULL &&
*(authmethods[i]->enabled) != 0) {
if (buffer_len(&b) > 0) if (buffer_len(&b) > 0)
buffer_append(&b, ",", 1); buffer_append(&b, ",", 1);
buffer_append(&b, method->name, strlen(method->name)); buffer_append(&b, authmethods[i]->name,
strlen(authmethods[i]->name));
} }
} }
buffer_append(&b, "\0", 1); buffer_append(&b, "\0", 1);
@ -618,13 +608,15 @@ authmethods_get(void)
static Authmethod * static Authmethod *
authmethod_lookup(const char *name) authmethod_lookup(const char *name)
{ {
Authmethod *method = NULL; int i;
if (name != NULL) if (name != NULL)
for (method = authmethods; method->name != NULL; method++) for (i = 0; authmethods[i] != NULL; i++)
if (method->enabled != NULL && if (authmethods[i]->enabled != NULL &&
*(method->enabled) != 0 && *(authmethods[i]->enabled) != 0 &&
strcmp(name, method->name) == 0) strcmp(name, authmethods[i]->name) == 0)
return method; return authmethods[i];
debug2("Unrecognized authentication method name: %s", name ? name : "NULL"); debug2("Unrecognized authentication method name: %s",
name ? name : "NULL");
return NULL; return NULL;
} }