xref: /titanic_52/usr/src/lib/nsswitch/files/common/tsol_gettpent.c (revision 88df2d76721d60b8b7cad14f9380446d06569f7c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include "files_common.h"
29 #include <sys/tsol/tndb.h>
30 #include <string.h>
31 
32 /*
33  *	files/tsol_gettpent.c --
34  *           "files" backend for nsswitch "tnrhtp" database
35  */
36 static int
37 check_name(nss_XbyY_args_t *args)
38 {
39 	tsol_tpstr_t	*tpstrp	= (tsol_tpstr_t *)args->returnval;
40 	const char	*name	= args->key.name;
41 
42 	if (strcmp(tpstrp->template, name) == 0)
43 		return (1);
44 
45 	return (0);
46 }
47 
48 static nss_status_t
49 getbyname(be, a)
50 	files_backend_ptr_t	be;
51 	void			*a;
52 {
53 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *)a;
54 
55 	return (_nss_files_XY_all(be, argp, 1, argp->key.name, check_name));
56 }
57 
58 static files_backend_op_t tsol_tp_ops[] = {
59 	_nss_files_destr,
60 	_nss_files_endent,
61 	_nss_files_setent,
62 	_nss_files_getent_netdb,
63 	getbyname
64 };
65 
66 nss_backend_t *
67 _nss_files_tnrhtp_constr(dummy1, dummy2, dummy3)
68 	const char	*dummy1, *dummy2, *dummy3;
69 {
70 	return (_nss_files_constr(tsol_tp_ops,
71 				sizeof (tsol_tp_ops) / sizeof (tsol_tp_ops[0]),
72 				"/etc/security/tsol/tnrhtp",
73 				NSS_LINELEN_TSOL_TP,
74 				NULL));
75 }
76