summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--auth.h16
-rw-r--r--auth2.c72
3 files changed, 44 insertions, 49 deletions
diff --git a/ChangeLog b/ChangeLog
index 4851d4a93..8248ab19c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -65,6 +65,9 @@
65 pass # of socket-fd to ssh-keysign, keysign verfies locally used 65 pass # of socket-fd to ssh-keysign, keysign verfies locally used
66 ip-address using this socket-fd, restricts fake local hostnames 66 ip-address using this socket-fd, restricts fake local hostnames
67 to actual local hostnames; ok stevesk@ 67 to actual local hostnames; ok stevesk@
68 - markus@cvs.openbsd.org 2002/05/31 11:35:15
69 [auth.h auth2.c]
70 move Authmethod definitons to per-method file.
68 71
6920020604 7220020604
70 - (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed 73 - (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed
@@ -749,4 +752,4 @@
749 - (stevesk) entropy.c: typo in debug message 752 - (stevesk) entropy.c: typo in debug message
750 - (djm) ssh-keygen -i needs seeded RNG; report from markus@ 753 - (djm) ssh-keygen -i needs seeded RNG; report from markus@
751 754
752$Id: ChangeLog,v 1.2162 2002/06/06 20:51:04 mouring Exp $ 755$Id: ChangeLog,v 1.2163 2002/06/06 20:52:37 mouring Exp $
diff --git a/auth.h b/auth.h
index 59646ebe4..d98547d02 100644
--- a/auth.h
+++ b/auth.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.h,v 1.38 2002/05/25 18:51:07 markus Exp $ */ 1/* $OpenBSD: auth.h,v 1.39 2002/05/31 11:35:15 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -43,6 +43,7 @@
43#endif 43#endif
44 44
45typedef struct Authctxt Authctxt; 45typedef struct Authctxt Authctxt;
46typedef struct Authmethod Authmethod;
46typedef struct KbdintDevice KbdintDevice; 47typedef struct KbdintDevice KbdintDevice;
47 48
48struct Authctxt { 49struct Authctxt {
@@ -71,6 +72,12 @@ struct Authctxt {
71#endif 72#endif
72}; 73};
73 74
75struct Authmethod {
76 char *name;
77 int (*userauth)(Authctxt *authctxt);
78 int *enabled;
79};
80
74/* 81/*
75 * Keyboard interactive device: 82 * Keyboard interactive device:
76 * init_ctx returns: non NULL upon success 83 * init_ctx returns: non NULL upon success
@@ -100,13 +107,6 @@ BIGNUM *auth_rsa_generate_challenge(Key *);
100int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]); 107int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]);
101int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **); 108int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
102 109
103/* ssh2 methods */
104int userauth_none(Authctxt *);
105int userauth_passwd(Authctxt *);
106int userauth_pubkey(Authctxt *);
107int userauth_hostbased(Authctxt *);
108int userauth_kbdint(Authctxt *);
109
110int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *); 110int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *);
111int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); 111int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
112int user_key_allowed(struct passwd *, Key *); 112int user_key_allowed(struct passwd *, Key *);
diff --git a/auth2.c b/auth2.c
index ffd703282..c7cc0c640 100644
--- a/auth2.c
+++ b/auth2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2.c,v 1.92 2002/05/25 18:51:07 markus Exp $"); 26RCSID("$OpenBSD: auth2.c,v 1.93 2002/05/31 11:35:15 markus Exp $");
27 27
28#include "ssh2.h" 28#include "ssh2.h"
29#include "xmalloc.h" 29#include "xmalloc.h"
@@ -42,13 +42,22 @@ extern u_char *session_id2;
42extern int session_id2_len; 42extern int session_id2_len;
43 43
44Authctxt *x_authctxt = NULL; 44Authctxt *x_authctxt = NULL;
45static int one = 1;
46 45
47typedef struct Authmethod Authmethod; 46/* methods */
48struct Authmethod { 47
49 char *name; 48extern Authmethod method_none;
50 int (*userauth)(Authctxt *authctxt); 49extern Authmethod method_pubkey;
51 int *enabled; 50extern Authmethod method_passwd;
51extern Authmethod method_kbdint;
52extern Authmethod method_hostbased;
53
54Authmethod *authmethods[] = {
55 &method_none,
56 &method_pubkey,
57 &method_passwd,
58 &method_kbdint,
59 &method_hostbased,
60 NULL
52}; 61};
53 62
54/* protocol */ 63/* protocol */
@@ -62,27 +71,6 @@ static char *authmethods_get(void);
62int user_key_allowed(struct passwd *, Key *); 71int user_key_allowed(struct passwd *, Key *);
63int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); 72int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
64 73
65/* auth */
66
67Authmethod authmethods[] = {
68 {"none",
69 userauth_none,
70 &one},
71 {"publickey",
72 userauth_pubkey,
73 &options.pubkey_authentication},
74 {"password",
75 userauth_passwd,
76 &options.password_authentication},
77 {"keyboard-interactive",
78 userauth_kbdint,
79 &options.kbd_interactive_authentication},
80 {"hostbased",
81 userauth_hostbased,
82 &options.hostbased_authentication},
83 {NULL, NULL, NULL}
84};
85
86/* 74/*
87 * loop until authctxt->success == TRUE 75 * loop until authctxt->success == TRUE
88 */ 76 */
@@ -595,18 +583,20 @@ auth_get_user(void)
595static char * 583static char *
596authmethods_get(void) 584authmethods_get(void)
597{ 585{
598 Authmethod *method = NULL;
599 Buffer b; 586 Buffer b;
600 char *list; 587 char *list;
588 int i;
601 589
602 buffer_init(&b); 590 buffer_init(&b);
603 for (method = authmethods; method->name != NULL; method++) { 591 for (i = 0; authmethods[i] != NULL; i++) {
604 if (strcmp(method->name, "none") == 0) 592 if (strcmp(authmethods[i]->name, "none") == 0)
605 continue; 593 continue;
606 if (method->enabled != NULL && *(method->enabled) != 0) { 594 if (authmethods[i]->enabled != NULL &&
595 *(authmethods[i]->enabled) != 0) {
607 if (buffer_len(&b) > 0) 596 if (buffer_len(&b) > 0)
608 buffer_append(&b, ",", 1); 597 buffer_append(&b, ",", 1);
609 buffer_append(&b, method->name, strlen(method->name)); 598 buffer_append(&b, authmethods[i]->name,
599 strlen(authmethods[i]->name));
610 } 600 }
611 } 601 }
612 buffer_append(&b, "\0", 1); 602 buffer_append(&b, "\0", 1);
@@ -618,13 +608,15 @@ authmethods_get(void)
618static Authmethod * 608static Authmethod *
619authmethod_lookup(const char *name) 609authmethod_lookup(const char *name)
620{ 610{
621 Authmethod *method = NULL; 611 int i;
612
622 if (name != NULL) 613 if (name != NULL)
623 for (method = authmethods; method->name != NULL; method++) 614 for (i = 0; authmethods[i] != NULL; i++)
624 if (method->enabled != NULL && 615 if (authmethods[i]->enabled != NULL &&
625 *(method->enabled) != 0 && 616 *(authmethods[i]->enabled) != 0 &&
626 strcmp(name, method->name) == 0) 617 strcmp(name, authmethods[i]->name) == 0)
627 return method; 618 return authmethods[i];
628 debug2("Unrecognized authentication method name: %s", name ? name : "NULL"); 619 debug2("Unrecognized authentication method name: %s",
620 name ? name : "NULL");
629 return NULL; 621 return NULL;
630} 622}