1 /*
2  * Copyright 2003,2004,2005 Red Hat, Inc.
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, and the entire permission notice in its entirety,
9  *    including the disclaimer of warranties.
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  * 3. The name of the author may not be used to endorse or promote
14  *    products derived from this software without specific prior
15  *    written permission.
16  *
17  * ALTERNATIVELY, this product may be distributed under the terms of the
18  * GNU Lesser General Public License, in which case the provisions of the
19  * LGPL are required INSTEAD OF the above restrictions.
20  *
21  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
24  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include "../config.h"
34 
35 #include <sys/types.h>
36 #include <stdlib.h>
37 
38 #ifdef HAVE_SECURITY_PAM_APPL_H
39 #include <security/pam_appl.h>
40 #endif
41 
42 #ifdef HAVE_SECURITY_PAM_MODULES_H
43 #include <security/pam_modules.h>
44 #endif
45 
46 #include "items.h"
47 
48 int
_pam_krb5_has_item(pam_handle_t * pamh,int item)49 _pam_krb5_has_item(pam_handle_t *pamh, int item)
50 {
51 	PAM_KRB5_MAYBE_CONST void *data;
52 	data = NULL;
53 	if ((pam_get_item(pamh, item, &data) == PAM_SUCCESS) &&
54 	    (data != NULL)) {
55 		return 1;
56 	}
57 	return 0;
58 }
59 
60 int
_pam_krb5_get_item_text(pam_handle_t * pamh,int item,char ** text)61 _pam_krb5_get_item_text(pam_handle_t *pamh, int item, char **text)
62 {
63 	if (item != PAM_CONV) {
64 		return pam_get_item(pamh, item,
65 				    (PAM_KRB5_MAYBE_CONST void**) text);
66 	}
67 	return PAM_SERVICE_ERR;
68 }
69 
70 int
_pam_krb5_get_item_conv(pam_handle_t * pamh,struct pam_conv ** conv)71 _pam_krb5_get_item_conv(pam_handle_t *pamh, struct pam_conv **conv)
72 {
73 	return pam_get_item(pamh, PAM_CONV, (PAM_KRB5_MAYBE_CONST void**) conv);
74 }
75