diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | auth.h | 16 | ||||
-rw-r--r-- | auth2.c | 72 |
3 files changed, 44 insertions, 49 deletions
@@ -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 | ||
69 | 20020604 | 72 | 20020604 |
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 $ |
@@ -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 | ||
45 | typedef struct Authctxt Authctxt; | 45 | typedef struct Authctxt Authctxt; |
46 | typedef struct Authmethod Authmethod; | ||
46 | typedef struct KbdintDevice KbdintDevice; | 47 | typedef struct KbdintDevice KbdintDevice; |
47 | 48 | ||
48 | struct Authctxt { | 49 | struct Authctxt { |
@@ -71,6 +72,12 @@ struct Authctxt { | |||
71 | #endif | 72 | #endif |
72 | }; | 73 | }; |
73 | 74 | ||
75 | struct 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 *); | |||
100 | int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]); | 107 | int auth_rsa_verify_response(Key *, BIGNUM *, u_char[]); |
101 | int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **); | 108 | int auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **); |
102 | 109 | ||
103 | /* ssh2 methods */ | ||
104 | int userauth_none(Authctxt *); | ||
105 | int userauth_passwd(Authctxt *); | ||
106 | int userauth_pubkey(Authctxt *); | ||
107 | int userauth_hostbased(Authctxt *); | ||
108 | int userauth_kbdint(Authctxt *); | ||
109 | |||
110 | int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *); | 110 | int auth_rhosts_rsa_key_allowed(struct passwd *, char *, char *, Key *); |
111 | int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); | 111 | int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); |
112 | int user_key_allowed(struct passwd *, Key *); | 112 | int user_key_allowed(struct passwd *, Key *); |
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: auth2.c,v 1.92 2002/05/25 18:51:07 markus Exp $"); | 26 | RCSID("$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; | |||
42 | extern int session_id2_len; | 42 | extern int session_id2_len; |
43 | 43 | ||
44 | Authctxt *x_authctxt = NULL; | 44 | Authctxt *x_authctxt = NULL; |
45 | static int one = 1; | ||
46 | 45 | ||
47 | typedef struct Authmethod Authmethod; | 46 | /* methods */ |
48 | struct Authmethod { | 47 | |
49 | char *name; | 48 | extern Authmethod method_none; |
50 | int (*userauth)(Authctxt *authctxt); | 49 | extern Authmethod method_pubkey; |
51 | int *enabled; | 50 | extern Authmethod method_passwd; |
51 | extern Authmethod method_kbdint; | ||
52 | extern Authmethod method_hostbased; | ||
53 | |||
54 | Authmethod *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); | |||
62 | int user_key_allowed(struct passwd *, Key *); | 71 | int user_key_allowed(struct passwd *, Key *); |
63 | int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); | 72 | int hostbased_key_allowed(struct passwd *, const char *, char *, Key *); |
64 | 73 | ||
65 | /* auth */ | ||
66 | |||
67 | Authmethod 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) | |||
595 | static char * | 583 | static char * |
596 | authmethods_get(void) | 584 | authmethods_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) | |||
618 | static Authmethod * | 608 | static Authmethod * |
619 | authmethod_lookup(const char *name) | 609 | authmethod_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 | } |