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