summaryrefslogtreecommitdiff
path: root/auth2-chall.c
diff options
context:
space:
mode:
authormarkus@openbsd.org <markus@openbsd.org>2017-05-30 14:29:59 +0000
committerDamien Miller <djm@mindrot.org>2017-05-31 10:50:33 +1000
commiteb272ea4099fd6157846f15c129ac5727933aa69 (patch)
tree7c721828dc6504e4adaa6517ce65840eaaba06ef /auth2-chall.c
parent5a146bbd4fdf5c571f9fb438e5210d28cead76d9 (diff)
upstream commit
switch auth2 to ssh_dispatch API; ok djm@ Upstream-ID: a752ca19e2782900dd83060b5c6344008106215f
Diffstat (limited to 'auth2-chall.c')
-rw-r--r--auth2-chall.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/auth2-chall.c b/auth2-chall.c
index 954eb4e18..11c8d31b3 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-chall.c,v 1.47 2017/05/30 14:23:52 markus Exp $ */ 1/* $OpenBSD: auth2-chall.c,v 1.48 2017/05/30 14:29:59 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2001 Per Allansson. All rights reserved. 4 * Copyright (c) 2001 Per Allansson. All rights reserved.
@@ -47,7 +47,7 @@
47/* import */ 47/* import */
48extern ServerOptions options; 48extern ServerOptions options;
49 49
50static int auth2_challenge_start(Authctxt *); 50static int auth2_challenge_start(struct ssh *);
51static int send_userauth_info_request(Authctxt *); 51static int send_userauth_info_request(Authctxt *);
52static int input_userauth_info_response(int, u_int32_t, struct ssh *); 52static int input_userauth_info_response(int, u_int32_t, struct ssh *);
53 53
@@ -195,8 +195,9 @@ kbdint_next_device(Authctxt *authctxt, KbdintAuthctxt *kbdintctxt)
195 * wait for the response. 195 * wait for the response.
196 */ 196 */
197int 197int
198auth2_challenge(Authctxt *authctxt, char *devs) 198auth2_challenge(struct ssh *ssh, char *devs)
199{ 199{
200 Authctxt *authctxt = ssh->authctxt;
200 debug("auth2_challenge: user=%s devs=%s", 201 debug("auth2_challenge: user=%s devs=%s",
201 authctxt->user ? authctxt->user : "<nouser>", 202 authctxt->user ? authctxt->user : "<nouser>",
202 devs ? devs : "<no devs>"); 203 devs ? devs : "<no devs>");
@@ -205,15 +206,16 @@ auth2_challenge(Authctxt *authctxt, char *devs)
205 return 0; 206 return 0;
206 if (authctxt->kbdintctxt == NULL) 207 if (authctxt->kbdintctxt == NULL)
207 authctxt->kbdintctxt = kbdint_alloc(devs); 208 authctxt->kbdintctxt = kbdint_alloc(devs);
208 return auth2_challenge_start(authctxt); 209 return auth2_challenge_start(ssh);
209} 210}
210 211
211/* unregister kbd-int callbacks and context */ 212/* unregister kbd-int callbacks and context */
212void 213void
213auth2_challenge_stop(Authctxt *authctxt) 214auth2_challenge_stop(struct ssh *ssh)
214{ 215{
216 Authctxt *authctxt = ssh->authctxt;
215 /* unregister callback */ 217 /* unregister callback */
216 dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); 218 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL);
217 if (authctxt->kbdintctxt != NULL) { 219 if (authctxt->kbdintctxt != NULL) {
218 kbdint_free(authctxt->kbdintctxt); 220 kbdint_free(authctxt->kbdintctxt);
219 authctxt->kbdintctxt = NULL; 221 authctxt->kbdintctxt = NULL;
@@ -222,29 +224,30 @@ auth2_challenge_stop(Authctxt *authctxt)
222 224
223/* side effect: sets authctxt->postponed if a reply was sent*/ 225/* side effect: sets authctxt->postponed if a reply was sent*/
224static int 226static int
225auth2_challenge_start(Authctxt *authctxt) 227auth2_challenge_start(struct ssh *ssh)
226{ 228{
229 Authctxt *authctxt = ssh->authctxt;
227 KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt; 230 KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt;
228 231
229 debug2("auth2_challenge_start: devices %s", 232 debug2("auth2_challenge_start: devices %s",
230 kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); 233 kbdintctxt->devices ? kbdintctxt->devices : "<empty>");
231 234
232 if (kbdint_next_device(authctxt, kbdintctxt) == 0) { 235 if (kbdint_next_device(authctxt, kbdintctxt) == 0) {
233 auth2_challenge_stop(authctxt); 236 auth2_challenge_stop(ssh);
234 return 0; 237 return 0;
235 } 238 }
236 debug("auth2_challenge_start: trying authentication method '%s'", 239 debug("auth2_challenge_start: trying authentication method '%s'",
237 kbdintctxt->device->name); 240 kbdintctxt->device->name);
238 241
239 if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) { 242 if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) {
240 auth2_challenge_stop(authctxt); 243 auth2_challenge_stop(ssh);
241 return 0; 244 return 0;
242 } 245 }
243 if (send_userauth_info_request(authctxt) == 0) { 246 if (send_userauth_info_request(authctxt) == 0) {
244 auth2_challenge_stop(authctxt); 247 auth2_challenge_stop(ssh);
245 return 0; 248 return 0;
246 } 249 }
247 dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, 250 ssh_dispatch_set(ssh, SSH2_MSG_USERAUTH_INFO_RESPONSE,
248 &input_userauth_info_response); 251 &input_userauth_info_response);
249 252
250 authctxt->postponed = 1; 253 authctxt->postponed = 1;
@@ -340,14 +343,14 @@ input_userauth_info_response(int type, u_int32_t seq, struct ssh *ssh)
340 devicename = kbdintctxt->device->name; 343 devicename = kbdintctxt->device->name;
341 if (!authctxt->postponed) { 344 if (!authctxt->postponed) {
342 if (authenticated) { 345 if (authenticated) {
343 auth2_challenge_stop(authctxt); 346 auth2_challenge_stop(ssh);
344 } else { 347 } else {
345 /* start next device */ 348 /* start next device */
346 /* may set authctxt->postponed */ 349 /* may set authctxt->postponed */
347 auth2_challenge_start(authctxt); 350 auth2_challenge_start(ssh);
348 } 351 }
349 } 352 }
350 userauth_finish(authctxt, authenticated, "keyboard-interactive", 353 userauth_finish(ssh, authenticated, "keyboard-interactive",
351 devicename); 354 devicename);
352 return 0; 355 return 0;
353} 356}