17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * Copyright (c) 2000 Markus Friedl. All rights reserved.
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
57c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions
67c478bd9Sstevel@tonic-gate * are met:
77c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
87c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
97c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
107c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
117c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
147c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
157c478bd9Sstevel@tonic-gate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
167c478bd9Sstevel@tonic-gate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
177c478bd9Sstevel@tonic-gate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
187c478bd9Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
197c478bd9Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
207c478bd9Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
217c478bd9Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
227c478bd9Sstevel@tonic-gate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
237c478bd9Sstevel@tonic-gate */
247c478bd9Sstevel@tonic-gate /*
25*4a2e944dSJan Pechanec * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate #include "includes.h"
297c478bd9Sstevel@tonic-gate RCSID("$OpenBSD: auth2-kbdint.c,v 1.2 2002/05/31 11:35:15 markus Exp $");
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate #include "packet.h"
327c478bd9Sstevel@tonic-gate #include "auth.h"
337c478bd9Sstevel@tonic-gate #include "log.h"
347c478bd9Sstevel@tonic-gate #include "servconf.h"
357c478bd9Sstevel@tonic-gate #include "xmalloc.h"
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate /* import */
387c478bd9Sstevel@tonic-gate extern ServerOptions options;
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate static void
userauth_kbdint(Authctxt * authctxt)417c478bd9Sstevel@tonic-gate userauth_kbdint(Authctxt *authctxt)
427c478bd9Sstevel@tonic-gate {
437c478bd9Sstevel@tonic-gate char *lang, *devs;
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gate if (!authctxt || !authctxt->method)
467c478bd9Sstevel@tonic-gate fatal("%s: missing contex", __func__);
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate lang = packet_get_string(NULL);
497c478bd9Sstevel@tonic-gate devs = packet_get_string(NULL);
507c478bd9Sstevel@tonic-gate packet_check_eom();
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate debug("keyboard-interactive devs %s", devs);
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate #ifdef USE_PAM
55*4a2e944dSJan Pechanec if (options.kbd_interactive_authentication)
567c478bd9Sstevel@tonic-gate auth2_pam(authctxt);
577c478bd9Sstevel@tonic-gate #else
587c478bd9Sstevel@tonic-gate if (options.challenge_response_authentication)
597c478bd9Sstevel@tonic-gate auth2_challenge(authctxt, devs);
607c478bd9Sstevel@tonic-gate #endif /* USE_PAM */
617c478bd9Sstevel@tonic-gate xfree(devs);
627c478bd9Sstevel@tonic-gate xfree(lang);
637c478bd9Sstevel@tonic-gate #ifdef HAVE_CYGWIN
647c478bd9Sstevel@tonic-gate if (check_nt_auth(0, authctxt->pw) == 0) {
657c478bd9Sstevel@tonic-gate authctxt->method->authenticated = 0;
667c478bd9Sstevel@tonic-gate return;
677c478bd9Sstevel@tonic-gate }
687c478bd9Sstevel@tonic-gate #endif
697c478bd9Sstevel@tonic-gate }
707c478bd9Sstevel@tonic-gate
717c478bd9Sstevel@tonic-gate static void
userauth_kbdint_abandon(Authctxt * authctxt,Authmethod * method)727c478bd9Sstevel@tonic-gate userauth_kbdint_abandon(Authctxt *authctxt, Authmethod *method)
737c478bd9Sstevel@tonic-gate {
747c478bd9Sstevel@tonic-gate #ifdef USE_PAM
757c478bd9Sstevel@tonic-gate kbdint_pam_abandon(authctxt, method);
767c478bd9Sstevel@tonic-gate #else
777c478bd9Sstevel@tonic-gate auth2_challenge_abandon(authctxt);
787c478bd9Sstevel@tonic-gate #endif /* USE_PAM */
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate Authmethod method_kbdint = {
827c478bd9Sstevel@tonic-gate "keyboard-interactive",
837c478bd9Sstevel@tonic-gate &options.kbd_interactive_authentication,
847c478bd9Sstevel@tonic-gate userauth_kbdint,
857c478bd9Sstevel@tonic-gate userauth_kbdint_abandon,
867c478bd9Sstevel@tonic-gate NULL, NULL, /* method data and historical data */
877c478bd9Sstevel@tonic-gate 1, /* initial userauth */
887c478bd9Sstevel@tonic-gate 0, 0, 0, /* counters */
897c478bd9Sstevel@tonic-gate 0, 0, 0, 0, 0, 0 /* state */
907c478bd9Sstevel@tonic-gate };
91