xref: /titanic_41/usr/src/cmd/ssh/sshd/auth2-kbdint.c (revision 0fbb751d81ab0a7c7ddfd8d4e447e075a9f7024f)
1 /*
2  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24 /*
25  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
26  */
27 
28 #include "includes.h"
29 RCSID("$OpenBSD: auth2-kbdint.c,v 1.2 2002/05/31 11:35:15 markus Exp $");
30 
31 #include "packet.h"
32 #include "auth.h"
33 #include "log.h"
34 #include "servconf.h"
35 #include "xmalloc.h"
36 
37 /* import */
38 extern ServerOptions options;
39 
40 static void
41 userauth_kbdint(Authctxt *authctxt)
42 {
43 	char *lang, *devs;
44 
45 	if (!authctxt || !authctxt->method)
46 		fatal("%s: missing contex", __func__);
47 
48 	lang = packet_get_string(NULL);
49 	devs = packet_get_string(NULL);
50 	packet_check_eom();
51 
52 	debug("keyboard-interactive devs %s", devs);
53 
54 #ifdef USE_PAM
55 	if (options.kbd_interactive_authentication)
56 		auth2_pam(authctxt);
57 #else
58 	if (options.challenge_response_authentication)
59 		auth2_challenge(authctxt, devs);
60 #endif /* USE_PAM */
61 	xfree(devs);
62 	xfree(lang);
63 #ifdef HAVE_CYGWIN
64 	if (check_nt_auth(0, authctxt->pw) == 0) {
65 		authctxt->method->authenticated = 0;
66 		return;
67 	}
68 #endif
69 }
70 
71 static void
72 userauth_kbdint_abandon(Authctxt *authctxt, Authmethod *method)
73 {
74 #ifdef USE_PAM
75 	kbdint_pam_abandon(authctxt, method);
76 #else
77 	auth2_challenge_abandon(authctxt);
78 #endif /* USE_PAM */
79 }
80 
81 Authmethod method_kbdint = {
82 	"keyboard-interactive",
83 	&options.kbd_interactive_authentication,
84 	userauth_kbdint,
85 	userauth_kbdint_abandon,
86 	NULL, NULL,	    /* method data and historical data */
87 	1,		    /* initial userauth */
88 	0, 0, 0,	    /* counters */
89 	0, 0, 0, 0, 0, 0    /* state */
90 };
91