diff options
Diffstat (limited to 'auth-chall.c')
-rw-r--r-- | auth-chall.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/auth-chall.c b/auth-chall.c index b6ec02a38..926c07ede 100644 --- a/auth-chall.c +++ b/auth-chall.c | |||
@@ -26,7 +26,48 @@ | |||
26 | RCSID("$OpenBSD: auth-chall.c,v 1.4 2001/02/04 15:32:22 stevesk Exp $"); | 26 | RCSID("$OpenBSD: auth-chall.c,v 1.4 2001/02/04 15:32:22 stevesk Exp $"); |
27 | 27 | ||
28 | #include "auth.h" | 28 | #include "auth.h" |
29 | #include "log.h" | ||
29 | 30 | ||
31 | #ifdef BSD_AUTH | ||
32 | char * | ||
33 | get_challenge(Authctxt *authctxt, char *devs) | ||
34 | { | ||
35 | char *challenge; | ||
36 | |||
37 | if (authctxt->as != NULL) { | ||
38 | debug2("try reuse session"); | ||
39 | challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE); | ||
40 | if (challenge != NULL) { | ||
41 | debug2("reuse bsd auth session"); | ||
42 | return challenge; | ||
43 | } | ||
44 | auth_close(authctxt->as); | ||
45 | authctxt->as = NULL; | ||
46 | } | ||
47 | debug2("new bsd auth session"); | ||
48 | if (devs == NULL || strlen(devs) == 0) | ||
49 | devs = authctxt->style; | ||
50 | debug3("bsd auth: devs %s", devs ? devs : "<default>"); | ||
51 | authctxt->as = auth_userchallenge(authctxt->user, devs, "auth-ssh", | ||
52 | &challenge); | ||
53 | if (authctxt->as == NULL) | ||
54 | return NULL; | ||
55 | debug2("get_challenge: <%s>", challenge ? challenge : "EMPTY"); | ||
56 | return challenge; | ||
57 | } | ||
58 | int | ||
59 | verify_response(Authctxt *authctxt, char *response) | ||
60 | { | ||
61 | int authok; | ||
62 | |||
63 | if (authctxt->as == 0) | ||
64 | error("verify_response: no bsd auth session"); | ||
65 | authok = auth_userresponse(authctxt->as, response, 0); | ||
66 | authctxt->as = NULL; | ||
67 | debug("verify_response: <%s> = <%d>", response, authok); | ||
68 | return authok != 0; | ||
69 | } | ||
70 | #else | ||
30 | #ifdef SKEY | 71 | #ifdef SKEY |
31 | #include <skey.h> | 72 | #include <skey.h> |
32 | 73 | ||
@@ -60,3 +101,4 @@ verify_response(Authctxt *authctxt, char *response) | |||
60 | return 0; | 101 | return 0; |
61 | } | 102 | } |
62 | #endif | 103 | #endif |
104 | #endif | ||