Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 1 | /* |
Ben Lindstrom | 92a2e38 | 2001-03-05 06:59:27 +0000 | [diff] [blame] | 2 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 3 | * Copyright (c) 2001 Per Allansson. All rights reserved. |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | #include "includes.h" |
Darren Tucker | 611649e | 2005-01-20 11:05:34 +1100 | [diff] [blame^] | 26 | RCSID("$OpenBSD: auth2-chall.c,v 1.22 2005/01/19 13:11:47 dtucker Exp $"); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 27 | |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 28 | #include "ssh2.h" |
| 29 | #include "auth.h" |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 30 | #include "buffer.h" |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 31 | #include "packet.h" |
| 32 | #include "xmalloc.h" |
| 33 | #include "dispatch.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 34 | #include "log.h" |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 35 | |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 36 | static int auth2_challenge_start(Authctxt *); |
| 37 | static int send_userauth_info_request(Authctxt *); |
Damien Miller | 630d6f4 | 2002-01-22 23:17:30 +1100 | [diff] [blame] | 38 | static void input_userauth_info_response(int, u_int32_t, void *); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 39 | |
| 40 | #ifdef BSD_AUTH |
| 41 | extern KbdintDevice bsdauth_device; |
| 42 | #else |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 43 | #ifdef USE_PAM |
| 44 | extern KbdintDevice sshpam_device; |
| 45 | #endif |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 46 | #ifdef SKEY |
| 47 | extern KbdintDevice skey_device; |
| 48 | #endif |
| 49 | #endif |
| 50 | |
| 51 | KbdintDevice *devices[] = { |
| 52 | #ifdef BSD_AUTH |
| 53 | &bsdauth_device, |
| 54 | #else |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 55 | #ifdef USE_PAM |
| 56 | &sshpam_device, |
| 57 | #endif |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 58 | #ifdef SKEY |
| 59 | &skey_device, |
| 60 | #endif |
| 61 | #endif |
| 62 | NULL |
| 63 | }; |
| 64 | |
| 65 | typedef struct KbdintAuthctxt KbdintAuthctxt; |
| 66 | struct KbdintAuthctxt |
| 67 | { |
| 68 | char *devices; |
| 69 | void *ctxt; |
| 70 | KbdintDevice *device; |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 71 | u_int nreq; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 74 | static KbdintAuthctxt * |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 75 | kbdint_alloc(const char *devs) |
| 76 | { |
| 77 | KbdintAuthctxt *kbdintctxt; |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 78 | Buffer b; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 79 | int i; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 80 | |
| 81 | kbdintctxt = xmalloc(sizeof(KbdintAuthctxt)); |
| 82 | if (strcmp(devs, "") == 0) { |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 83 | buffer_init(&b); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 84 | for (i = 0; devices[i]; i++) { |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 85 | if (buffer_len(&b) > 0) |
| 86 | buffer_append(&b, ",", 1); |
| 87 | buffer_append(&b, devices[i]->name, |
| 88 | strlen(devices[i]->name)); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 89 | } |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 90 | buffer_append(&b, "\0", 1); |
| 91 | kbdintctxt->devices = xstrdup(buffer_ptr(&b)); |
| 92 | buffer_free(&b); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 93 | } else { |
| 94 | kbdintctxt->devices = xstrdup(devs); |
| 95 | } |
Damien Miller | 0e3b872 | 2002-01-22 23:26:38 +1100 | [diff] [blame] | 96 | debug("kbdint_alloc: devices '%s'", kbdintctxt->devices); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 97 | kbdintctxt->ctxt = NULL; |
| 98 | kbdintctxt->device = NULL; |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 99 | kbdintctxt->nreq = 0; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 100 | |
| 101 | return kbdintctxt; |
| 102 | } |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 103 | static void |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 104 | kbdint_reset_device(KbdintAuthctxt *kbdintctxt) |
| 105 | { |
| 106 | if (kbdintctxt->ctxt) { |
| 107 | kbdintctxt->device->free_ctx(kbdintctxt->ctxt); |
| 108 | kbdintctxt->ctxt = NULL; |
| 109 | } |
| 110 | kbdintctxt->device = NULL; |
| 111 | } |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 112 | static void |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 113 | kbdint_free(KbdintAuthctxt *kbdintctxt) |
| 114 | { |
| 115 | if (kbdintctxt->device) |
| 116 | kbdint_reset_device(kbdintctxt); |
| 117 | if (kbdintctxt->devices) { |
| 118 | xfree(kbdintctxt->devices); |
| 119 | kbdintctxt->devices = NULL; |
| 120 | } |
| 121 | xfree(kbdintctxt); |
| 122 | } |
| 123 | /* get next device */ |
Ben Lindstrom | bba8121 | 2001-06-25 05:01:22 +0000 | [diff] [blame] | 124 | static int |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 125 | kbdint_next_device(KbdintAuthctxt *kbdintctxt) |
| 126 | { |
| 127 | size_t len; |
| 128 | char *t; |
| 129 | int i; |
| 130 | |
| 131 | if (kbdintctxt->device) |
| 132 | kbdint_reset_device(kbdintctxt); |
| 133 | do { |
| 134 | len = kbdintctxt->devices ? |
| 135 | strcspn(kbdintctxt->devices, ",") : 0; |
| 136 | |
| 137 | if (len == 0) |
| 138 | break; |
| 139 | for (i = 0; devices[i]; i++) |
| 140 | if (strncmp(kbdintctxt->devices, devices[i]->name, len) == 0) |
| 141 | kbdintctxt->device = devices[i]; |
| 142 | t = kbdintctxt->devices; |
| 143 | kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL; |
| 144 | xfree(t); |
| 145 | debug2("kbdint_next_device: devices %s", kbdintctxt->devices ? |
| 146 | kbdintctxt->devices : "<empty>"); |
| 147 | } while (kbdintctxt->devices && !kbdintctxt->device); |
| 148 | |
| 149 | return kbdintctxt->device ? 1 : 0; |
| 150 | } |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 151 | |
| 152 | /* |
Ben Lindstrom | bdfb4df | 2001-10-03 17:12:43 +0000 | [diff] [blame] | 153 | * try challenge-response, set authctxt->postponed if we have to |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 154 | * wait for the response. |
| 155 | */ |
| 156 | int |
| 157 | auth2_challenge(Authctxt *authctxt, char *devs) |
| 158 | { |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 159 | debug("auth2_challenge: user=%s devs=%s", |
| 160 | authctxt->user ? authctxt->user : "<nouser>", |
| 161 | devs ? devs : "<no devs>"); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 162 | |
Ben Lindstrom | 742e89e | 2001-06-09 01:17:23 +0000 | [diff] [blame] | 163 | if (authctxt->user == NULL || !devs) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 164 | return 0; |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 165 | if (authctxt->kbdintctxt == NULL) |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 166 | authctxt->kbdintctxt = kbdint_alloc(devs); |
| 167 | return auth2_challenge_start(authctxt); |
| 168 | } |
| 169 | |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 170 | /* unregister kbd-int callbacks and context */ |
| 171 | void |
| 172 | auth2_challenge_stop(Authctxt *authctxt) |
| 173 | { |
| 174 | /* unregister callback */ |
| 175 | dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); |
| 176 | if (authctxt->kbdintctxt != NULL) { |
| 177 | kbdint_free(authctxt->kbdintctxt); |
| 178 | authctxt->kbdintctxt = NULL; |
| 179 | } |
| 180 | } |
| 181 | |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 182 | /* side effect: sets authctxt->postponed if a reply was sent*/ |
| 183 | static int |
| 184 | auth2_challenge_start(Authctxt *authctxt) |
| 185 | { |
| 186 | KbdintAuthctxt *kbdintctxt = authctxt->kbdintctxt; |
| 187 | |
| 188 | debug2("auth2_challenge_start: devices %s", |
| 189 | kbdintctxt->devices ? kbdintctxt->devices : "<empty>"); |
| 190 | |
| 191 | if (kbdint_next_device(kbdintctxt) == 0) { |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 192 | auth2_challenge_stop(authctxt); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 193 | return 0; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 194 | } |
| 195 | debug("auth2_challenge_start: trying authentication method '%s'", |
| 196 | kbdintctxt->device->name); |
| 197 | |
| 198 | if ((kbdintctxt->ctxt = kbdintctxt->device->init_ctx(authctxt)) == NULL) { |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 199 | auth2_challenge_stop(authctxt); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | if (send_userauth_info_request(authctxt) == 0) { |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 203 | auth2_challenge_stop(authctxt); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 204 | return 0; |
| 205 | } |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 206 | dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, |
| 207 | &input_userauth_info_response); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 208 | |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 209 | authctxt->postponed = 1; |
| 210 | return 0; |
| 211 | } |
| 212 | |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 213 | static int |
| 214 | send_userauth_info_request(Authctxt *authctxt) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 215 | { |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 216 | KbdintAuthctxt *kbdintctxt; |
| 217 | char *name, *instr, **prompts; |
| 218 | int i; |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 219 | u_int *echo_on; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 220 | |
| 221 | kbdintctxt = authctxt->kbdintctxt; |
| 222 | if (kbdintctxt->device->query(kbdintctxt->ctxt, |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 223 | &name, &instr, &kbdintctxt->nreq, &prompts, &echo_on)) |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 224 | return 0; |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 225 | |
| 226 | packet_start(SSH2_MSG_USERAUTH_INFO_REQUEST); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 227 | packet_put_cstring(name); |
| 228 | packet_put_cstring(instr); |
Ben Lindstrom | cb72e4f | 2002-06-21 00:41:51 +0000 | [diff] [blame] | 229 | packet_put_cstring(""); /* language not used */ |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 230 | packet_put_int(kbdintctxt->nreq); |
| 231 | for (i = 0; i < kbdintctxt->nreq; i++) { |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 232 | packet_put_cstring(prompts[i]); |
| 233 | packet_put_char(echo_on[i]); |
| 234 | } |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 235 | packet_send(); |
| 236 | packet_write_wait(); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 237 | |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 238 | for (i = 0; i < kbdintctxt->nreq; i++) |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 239 | xfree(prompts[i]); |
| 240 | xfree(prompts); |
| 241 | xfree(echo_on); |
| 242 | xfree(name); |
| 243 | xfree(instr); |
| 244 | return 1; |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 245 | } |
| 246 | |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 247 | static void |
Damien Miller | 630d6f4 | 2002-01-22 23:17:30 +1100 | [diff] [blame] | 248 | input_userauth_info_response(int type, u_int32_t seq, void *ctxt) |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 249 | { |
| 250 | Authctxt *authctxt = ctxt; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 251 | KbdintAuthctxt *kbdintctxt; |
| 252 | int i, authenticated = 0, res, len; |
| 253 | u_int nresp; |
| 254 | char **response = NULL, *method; |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 255 | |
| 256 | if (authctxt == NULL) |
| 257 | fatal("input_userauth_info_response: no authctxt"); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 258 | kbdintctxt = authctxt->kbdintctxt; |
| 259 | if (kbdintctxt == NULL || kbdintctxt->ctxt == NULL) |
| 260 | fatal("input_userauth_info_response: no kbdintctxt"); |
| 261 | if (kbdintctxt->device == NULL) |
| 262 | fatal("input_userauth_info_response: no device"); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 263 | |
| 264 | authctxt->postponed = 0; /* reset */ |
| 265 | nresp = packet_get_int(); |
Damien Miller | fb7fd95 | 2002-06-26 23:58:39 +1000 | [diff] [blame] | 266 | if (nresp != kbdintctxt->nreq) |
| 267 | fatal("input_userauth_info_response: wrong number of replies"); |
| 268 | if (nresp > 100) |
| 269 | fatal("input_userauth_info_response: too many replies"); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 270 | if (nresp > 0) { |
Ben Lindstrom | a962c2f | 2002-07-04 00:14:17 +0000 | [diff] [blame] | 271 | response = xmalloc(nresp * sizeof(char *)); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 272 | for (i = 0; i < nresp; i++) |
| 273 | response[i] = packet_get_string(NULL); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 274 | } |
Damien Miller | 48b03fc | 2002-01-22 23:11:40 +1100 | [diff] [blame] | 275 | packet_check_eom(); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 276 | |
Darren Tucker | 611649e | 2005-01-20 11:05:34 +1100 | [diff] [blame^] | 277 | res = kbdintctxt->device->respond(kbdintctxt->ctxt, nresp, response); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 278 | |
| 279 | for (i = 0; i < nresp; i++) { |
| 280 | memset(response[i], 'r', strlen(response[i])); |
| 281 | xfree(response[i]); |
| 282 | } |
| 283 | if (response) |
| 284 | xfree(response); |
| 285 | |
| 286 | switch (res) { |
| 287 | case 0: |
| 288 | /* Success! */ |
Darren Tucker | 611649e | 2005-01-20 11:05:34 +1100 | [diff] [blame^] | 289 | authenticated = authctxt->valid ? 1 : 0; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 290 | break; |
| 291 | case 1: |
| 292 | /* Authentication needs further interaction */ |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 293 | if (send_userauth_info_request(authctxt) == 1) |
| 294 | authctxt->postponed = 1; |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 295 | break; |
| 296 | default: |
| 297 | /* Failure! */ |
| 298 | break; |
| 299 | } |
| 300 | |
| 301 | len = strlen("keyboard-interactive") + 2 + |
| 302 | strlen(kbdintctxt->device->name); |
| 303 | method = xmalloc(len); |
Damien Miller | 209ee4e | 2002-01-22 23:25:08 +1100 | [diff] [blame] | 304 | snprintf(method, len, "keyboard-interactive/%s", |
| 305 | kbdintctxt->device->name); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 306 | |
| 307 | if (!authctxt->postponed) { |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 308 | if (authenticated) { |
Damien Miller | ee11625 | 2001-12-21 12:42:34 +1100 | [diff] [blame] | 309 | auth2_challenge_stop(authctxt); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 310 | } else { |
| 311 | /* start next device */ |
| 312 | /* may set authctxt->postponed */ |
| 313 | auth2_challenge_start(authctxt); |
| 314 | } |
| 315 | } |
Damien Miller | 5d57e50 | 2001-03-30 10:48:31 +1000 | [diff] [blame] | 316 | userauth_finish(authctxt, authenticated, method); |
Ben Lindstrom | 551ea37 | 2001-06-05 18:56:16 +0000 | [diff] [blame] | 317 | xfree(method); |
Ben Lindstrom | db65e8f | 2001-01-19 04:26:52 +0000 | [diff] [blame] | 318 | } |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 319 | |
| 320 | void |
| 321 | privsep_challenge_enable(void) |
| 322 | { |
Damien Miller | a6a7c19 | 2003-05-26 21:36:13 +1000 | [diff] [blame] | 323 | #if defined(BSD_AUTH) || defined(USE_PAM) || defined(SKEY) |
| 324 | int n = 0; |
| 325 | #endif |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 326 | #ifdef BSD_AUTH |
| 327 | extern KbdintDevice mm_bsdauth_device; |
| 328 | #endif |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 329 | #ifdef USE_PAM |
| 330 | extern KbdintDevice mm_sshpam_device; |
| 331 | #endif |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 332 | #ifdef SKEY |
| 333 | extern KbdintDevice mm_skey_device; |
| 334 | #endif |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 335 | |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 336 | #ifdef BSD_AUTH |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 337 | devices[n++] = &mm_bsdauth_device; |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 338 | #else |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 339 | #ifdef USE_PAM |
| 340 | devices[n++] = &mm_sshpam_device; |
| 341 | #endif |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 342 | #ifdef SKEY |
Damien Miller | 4f9f42a | 2003-05-10 19:28:02 +1000 | [diff] [blame] | 343 | devices[n++] = &mm_skey_device; |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 344 | #endif |
| 345 | #endif |
| 346 | } |