10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * Copyright (c) 2000 Markus Friedl. All rights reserved.
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
50Sstevel@tonic-gate * modification, are permitted provided that the following conditions
60Sstevel@tonic-gate * are met:
70Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
80Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
90Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
100Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
110Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
140Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
150Sstevel@tonic-gate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
160Sstevel@tonic-gate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
170Sstevel@tonic-gate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
180Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
190Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
200Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
210Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
220Sstevel@tonic-gate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
230Sstevel@tonic-gate */
240Sstevel@tonic-gate /*
25*12597SJan.Pechanec@Sun.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
260Sstevel@tonic-gate */
270Sstevel@tonic-gate
280Sstevel@tonic-gate #include "includes.h"
290Sstevel@tonic-gate RCSID("$OpenBSD: auth2-kbdint.c,v 1.2 2002/05/31 11:35:15 markus Exp $");
300Sstevel@tonic-gate
310Sstevel@tonic-gate #include "packet.h"
320Sstevel@tonic-gate #include "auth.h"
330Sstevel@tonic-gate #include "log.h"
340Sstevel@tonic-gate #include "servconf.h"
350Sstevel@tonic-gate #include "xmalloc.h"
360Sstevel@tonic-gate
370Sstevel@tonic-gate /* import */
380Sstevel@tonic-gate extern ServerOptions options;
390Sstevel@tonic-gate
400Sstevel@tonic-gate static void
userauth_kbdint(Authctxt * authctxt)410Sstevel@tonic-gate userauth_kbdint(Authctxt *authctxt)
420Sstevel@tonic-gate {
430Sstevel@tonic-gate char *lang, *devs;
440Sstevel@tonic-gate
450Sstevel@tonic-gate if (!authctxt || !authctxt->method)
460Sstevel@tonic-gate fatal("%s: missing contex", __func__);
470Sstevel@tonic-gate
480Sstevel@tonic-gate lang = packet_get_string(NULL);
490Sstevel@tonic-gate devs = packet_get_string(NULL);
500Sstevel@tonic-gate packet_check_eom();
510Sstevel@tonic-gate
520Sstevel@tonic-gate debug("keyboard-interactive devs %s", devs);
530Sstevel@tonic-gate
540Sstevel@tonic-gate #ifdef USE_PAM
55*12597SJan.Pechanec@Sun.COM if (options.kbd_interactive_authentication)
560Sstevel@tonic-gate auth2_pam(authctxt);
570Sstevel@tonic-gate #else
580Sstevel@tonic-gate if (options.challenge_response_authentication)
590Sstevel@tonic-gate auth2_challenge(authctxt, devs);
600Sstevel@tonic-gate #endif /* USE_PAM */
610Sstevel@tonic-gate xfree(devs);
620Sstevel@tonic-gate xfree(lang);
630Sstevel@tonic-gate #ifdef HAVE_CYGWIN
640Sstevel@tonic-gate if (check_nt_auth(0, authctxt->pw) == 0) {
650Sstevel@tonic-gate authctxt->method->authenticated = 0;
660Sstevel@tonic-gate return;
670Sstevel@tonic-gate }
680Sstevel@tonic-gate #endif
690Sstevel@tonic-gate }
700Sstevel@tonic-gate
710Sstevel@tonic-gate static void
userauth_kbdint_abandon(Authctxt * authctxt,Authmethod * method)720Sstevel@tonic-gate userauth_kbdint_abandon(Authctxt *authctxt, Authmethod *method)
730Sstevel@tonic-gate {
740Sstevel@tonic-gate #ifdef USE_PAM
750Sstevel@tonic-gate kbdint_pam_abandon(authctxt, method);
760Sstevel@tonic-gate #else
770Sstevel@tonic-gate auth2_challenge_abandon(authctxt);
780Sstevel@tonic-gate #endif /* USE_PAM */
790Sstevel@tonic-gate }
800Sstevel@tonic-gate
810Sstevel@tonic-gate Authmethod method_kbdint = {
820Sstevel@tonic-gate "keyboard-interactive",
830Sstevel@tonic-gate &options.kbd_interactive_authentication,
840Sstevel@tonic-gate userauth_kbdint,
850Sstevel@tonic-gate userauth_kbdint_abandon,
860Sstevel@tonic-gate NULL, NULL, /* method data and historical data */
870Sstevel@tonic-gate 1, /* initial userauth */
880Sstevel@tonic-gate 0, 0, 0, /* counters */
890Sstevel@tonic-gate 0, 0, 0, 0, 0, 0 /* state */
900Sstevel@tonic-gate };
91