version 1.8, 2001/09/27 15:31:17 |
version 1.9, 2001/12/09 18:45:56 |
|
|
return auth2_challenge_start(authctxt); |
return auth2_challenge_start(authctxt); |
} |
} |
|
|
|
/* unregister kbd-int callbacks and context */ |
|
void |
|
auth2_challenge_stop(Authctxt *authctxt) |
|
{ |
|
/* unregister callback */ |
|
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); |
|
if (authctxt->kbdintctxt != NULL) { |
|
kbdint_free(authctxt->kbdintctxt); |
|
authctxt->kbdintctxt = NULL; |
|
} |
|
} |
|
|
/* side effect: sets authctxt->postponed if a reply was sent*/ |
/* side effect: sets authctxt->postponed if a reply was sent*/ |
static int |
static int |
auth2_challenge_start(Authctxt *authctxt) |
auth2_challenge_start(Authctxt *authctxt) |
|
|
kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); |
kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); |
|
|
if (kbdint_next_device(kbdintctxt) == 0) { |
if (kbdint_next_device(kbdintctxt) == 0) { |
kbdint_free(kbdintctxt); |
auth2_challenge_stop(authctxt); |
authctxt->kbdintctxt = NULL; |
|
return 0; |
return 0; |
} |
} |
debug("auth2_challenge_start: trying authentication method '%s'", |
debug("auth2_challenge_start: trying authentication method '%s'", |
kbdintctxt->device->name); |
kbdintctxt->device->name); |
|
|
if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) { |
if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) { |
kbdint_free(kbdintctxt); |
auth2_challenge_stop(authctxt); |
authctxt->kbdintctxt = NULL; |
|
return 0; |
return 0; |
} |
} |
if (send_userauth_info_request(authctxt) == 0) { |
if (send_userauth_info_request(authctxt) == 0) { |
kbdint_free(kbdintctxt); |
auth2_challenge_stop(authctxt); |
authctxt->kbdintctxt = NULL; |
|
return 0; |
return 0; |
} |
} |
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, |
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, |
|
|
break; |
break; |
case 1: |
case 1: |
/* Authentication needs further interaction */ |
/* Authentication needs further interaction */ |
authctxt->postponed = 1; |
if (send_userauth_info_request(authctxt) == 1) |
if (send_userauth_info_request(authctxt) == 0) { |
authctxt->postponed = 1; |
authctxt->postponed = 0; |
|
} |
|
break; |
break; |
default: |
default: |
/* Failure! */ |
/* Failure! */ |
|
|
strlcat(method, kbdintctxt->device->name, len); |
strlcat(method, kbdintctxt->device->name, len); |
|
|
if (!authctxt->postponed) { |
if (!authctxt->postponed) { |
/* unregister callback */ |
|
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); |
|
|
|
if (authenticated) { |
if (authenticated) { |
kbdint_free(kbdintctxt); |
auth2_challenge_stop(authctxt); |
authctxt->kbdintctxt = NULL; |
|
} else { |
} else { |
/* start next device */ |
/* start next device */ |
/* may set authctxt->postponed */ |
/* may set authctxt->postponed */ |