xref: /titanic_52/usr/src/lib/nsswitch/nis/common/nis_common.h (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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 /*
27  * nis_common.h
28  *
29  * Common code and structures used by name-service-switch "nis" backends.
30  */
31 
32 #ifndef _NIS_COMMON_H
33 #define	_NIS_COMMON_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <nss_dbdefs.h>
38 #include <signal.h>
39 #include <rpcsvc/ypclnt.h>
40 #include <rpcsvc/yp_prot.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 #define	NIS_MAP_AUDITUSER	"audit_user"
47 #define	NIS_MAP_AUTHATTR	"auth_attr"
48 #define	NIS_MAP_EXECATTR	"exec_attr"
49 #define	NIS_MAP_PROFATTR	"prof_attr"
50 #define	NIS_MAP_USERATTR	"user_attr"
51 
52 
53 typedef struct nis_backend *nis_backend_ptr_t;
54 typedef nss_status_t	(*nis_backend_op_t)(nis_backend_ptr_t, void *);
55 
56 struct nis_backend {
57 	nis_backend_op_t	*ops;
58 	nss_dbop_t		n_ops;
59 	const char		*domain;
60 	const char		*enum_map;
61 	char			*enum_key;
62 	int			enum_keylen;
63 };
64 
65 /*
66  * Iterator function for _nss_nis_do_all(), which probably calls yp_all().
67  *   NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
68  *   other values don't make much sense.  In other words we're abusing
69  *   (overloading) the meaning of nss_status_t, but hey...
70  * _nss_nis_XY_all() is a wrapper around _nss_nis_do_all() that does the
71  *   generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
72  */
73 typedef nss_status_t	(*nis_do_all_func_t)(const char *, int, void *priv);
74 typedef int		(*nis_XY_check_func)(nss_XbyY_args_t *);
75 
76 extern nss_backend_t	*_nss_nis_constr(nis_backend_op_t	*ops,
77 					int			n_ops,
78 					const char		*map);
79 extern nss_status_t	_nss_nis_destr(nis_backend_ptr_t, void *dummy);
80 extern nss_status_t	_nss_nis_setent(nis_backend_ptr_t, void *dummy);
81 extern nss_status_t  	_nss_nis_endent(nis_backend_ptr_t, void *dummy);
82 extern nss_status_t  	_nss_nis_getent_rigid(nis_backend_ptr_t, void *);
83 extern nss_status_t  	_nss_nis_getent_netdb(nis_backend_ptr_t, void *);
84 extern nss_status_t 	_nss_nis_do_all(nis_backend_ptr_t,
85 					void			*func_priv,
86 					const char		*filter,
87 					nis_do_all_func_t	func);
88 extern nss_status_t 	_nss_nis_XY_all(nis_backend_ptr_t,
89 					nss_XbyY_args_t		*check_args,
90 					int			netdb,
91 					const char		*filter,
92 					nis_XY_check_func	check);
93 extern nss_status_t	_nss_nis_lookup(nis_backend_ptr_t,
94 					nss_XbyY_args_t		*args,
95 					int			netdb,
96 					const char		*map,
97 					const char		*key,
98 					int			*yp_statusp);
99 extern nss_status_t _nss_nis_lookup_rsvdport(nis_backend_ptr_t   be,
100 					nss_XbyY_args_t	*args,
101 					int netdb,
102 					const char	*map,
103 					const char	*key,
104 					int	*ypstatusp);
105 
106 /* Lower-level interface */
107 extern nss_status_t	_nss_nis_ypmatch(const char		*domain,
108 					const char		*map,
109 					const char		*key,
110 					char			**valp,
111 					int			*vallenp,
112 					int			*yp_statusp);
113 extern const char	*_nss_nis_domain();
114 extern int __nss2herrno(nss_status_t nsstat);
115 extern int _thr_sigsetmask(int how, const sigset_t *set, sigset_t *oset);
116 extern int _mutex_lock(mutex_t *mp);
117 extern int _mutex_unlock(mutex_t *mp);
118 extern int _nss_nis_check_name_aliases(nss_XbyY_args_t *argp,
119 					const char *line,
120 					int linelen);
121 
122 /* private yp "configurable lookup persistence" interface in libnsl */
123 extern int __yp_match_cflookup(char *, char *, char *, int, char **,
124 			    int *, int *);
125 extern int __yp_match_rsvdport_cflookup(char *, char *, char *, int, char **,
126 				    int *, int *);
127 extern int __yp_first_cflookup(char *, char *, char **, int *, char **,
128 			    int *, int);
129 
130 extern int __yp_next_cflookup(char *, char *, char *, int, char **, int *,
131 			    char **, int  *, int);
132 
133 extern int __yp_all_cflookup(char *, char *, struct ypall_callback *, int);
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif /* _NIS_COMMON_H */
140