summaryrefslogtreecommitdiff
path: root/auth-chall.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth-chall.c')
-rw-r--r--auth-chall.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/auth-chall.c b/auth-chall.c
index 6b7c8bd13..a9d314dd2 100644
--- a/auth-chall.c
+++ b/auth-chall.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth-chall.c,v 1.8 2001/05/18 14:13:28 markus Exp $"); 26RCSID("$OpenBSD: auth-chall.c,v 1.9 2003/11/03 09:03:37 djm Exp $");
27 27
28#include "auth.h" 28#include "auth.h"
29#include "log.h" 29#include "log.h"
@@ -67,36 +67,38 @@ get_challenge(Authctxt *authctxt)
67int 67int
68verify_response(Authctxt *authctxt, const char *response) 68verify_response(Authctxt *authctxt, const char *response)
69{ 69{
70 char *resp[1]; 70 char *resp[1], *name, *info, **prompts;
71 int res; 71 u_int i, numprompts, *echo_on;
72 int authenticated = 0;
72 73
73 if (device == NULL) 74 if (device == NULL)
74 return 0; 75 return 0;
75 if (authctxt->kbdintctxt == NULL) 76 if (authctxt->kbdintctxt == NULL)
76 return 0; 77 return 0;
77 resp[0] = (char *)response; 78 resp[0] = (char *)response;
78 res = device->respond(authctxt->kbdintctxt, 1, resp); 79 switch (device->respond(authctxt->kbdintctxt, 1, resp)) {
79 if (res == 1) { 80 case 0: /* Success */
80 /* postponed - send a null query just in case */ 81 authenticated = 1;
81 char *name, *info, **prompts; 82 break;
82 u_int i, numprompts, *echo_on; 83 case 1: /* Postponed - retry with empty query for PAM */
84 if ((device->query(authctxt->kbdintctxt, &name, &info,
85 &numprompts, &prompts, &echo_on)) != 0)
86 break;
87 if (numprompts == 0 &&
88 device->respond(authctxt->kbdintctxt, 0, resp) == 0)
89 authenticated = 1;
83 90
84 res = device->query(authctxt->kbdintctxt, &name, &info, 91 for (i = 0; i < numprompts; i++)
85 &numprompts, &prompts, &echo_on); 92 xfree(prompts[i]);
86 if (res == 0) { 93 xfree(prompts);
87 for (i = 0; i < numprompts; i++) 94 xfree(name);
88 xfree(prompts[i]); 95 xfree(echo_on);
89 xfree(prompts); 96 xfree(info);
90 xfree(name); 97 break;
91 xfree(echo_on);
92 xfree(info);
93 }
94 /* if we received more prompts, we're screwed */
95 res = (numprompts != 0);
96 } 98 }
97 device->free_ctx(authctxt->kbdintctxt); 99 device->free_ctx(authctxt->kbdintctxt);
98 authctxt->kbdintctxt = NULL; 100 authctxt->kbdintctxt = NULL;
99 return res ? 0 : 1; 101 return authenticated;
100} 102}
101void 103void
102abandon_challenge_response(Authctxt *authctxt) 104abandon_challenge_response(Authctxt *authctxt)