summaryrefslogtreecommitdiffstats
path: root/auth-chall.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-02-18 17:01:00 +1100
committerDamien Miller <djm@mindrot.org>2001-02-18 17:01:00 +1100
commit60396b060b803fd2d20aa151dc0432a344f798b0 (patch)
tree6027eced4465cbb8ab7146ba6cd3f9a89c38bd03 /auth-chall.c
parent75da9a9e721bf0f73aab8a28505a62224c327d18 (diff)
- (djm) Merge BSD_AUTH support from Markus Friedl and David J. MacKenzie
enable with --with-bsd-auth.
Diffstat (limited to 'auth-chall.c')
-rw-r--r--auth-chall.c42
1 files changed, 42 insertions, 0 deletions
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 : "<default>");
+ 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 <skey.h>
@@ -60,3 +101,4 @@ verify_response(Authctxt *authctxt, char *response)
return 0;
}
#endif
+#endif