From 60396b060b803fd2d20aa151dc0432a344f798b0 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Sun, 18 Feb 2001 17:01:00 +1100 Subject: - (djm) Merge BSD_AUTH support from Markus Friedl and David J. MacKenzie enable with --with-bsd-auth. --- auth-chall.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'auth-chall.c') diff --git a/auth-chall.c b/auth-chall.c index b6ec02a3..926c07ed 100644 --- a/auth-chall.c +++ b/auth-chall.c @@ -26,7 +26,48 @@ RCSID("$OpenBSD: auth-chall.c,v 1.4 2001/02/04 15:32:22 stevesk Exp $"); #include "auth.h" +#include "log.h" +#ifdef BSD_AUTH +char * +get_challenge(Authctxt *authctxt, char *devs) +{ + char *challenge; + + if (authctxt->as != NULL) { + debug2("try reuse session"); + challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE); + if (challenge != NULL) { + debug2("reuse bsd auth session"); + return challenge; + } + auth_close(authctxt->as); + authctxt->as = NULL; + } + debug2("new bsd auth session"); + if (devs == NULL || strlen(devs) == 0) + devs = authctxt->style; + debug3("bsd auth: devs %s", devs ? devs : ""); + authctxt->as = auth_userchallenge(authctxt->user, devs, "auth-ssh", + &challenge); + if (authctxt->as == NULL) + return NULL; + debug2("get_challenge: <%s>", challenge ? challenge : "EMPTY"); + return challenge; +} +int +verify_response(Authctxt *authctxt, char *response) +{ + int authok; + + if (authctxt->as == 0) + error("verify_response: no bsd auth session"); + authok = auth_userresponse(authctxt->as, response, 0); + authctxt->as = NULL; + debug("verify_response: <%s> = <%d>", response, authok); + return authok != 0; +} +#else #ifdef SKEY #include @@ -60,3 +101,4 @@ verify_response(Authctxt *authctxt, char *response) return 0; } #endif +#endif -- cgit v1.2.3