xref: /titanic_44/usr/src/lib/nsswitch/nis/common/nis_common.h (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1998-2002 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 _mutex_lock(mutex_t *mp);
118 extern int _mutex_unlock(mutex_t *mp);
119 
120 /* private yp "configurable lookup persistence" interface in libnsl */
121 extern int __yp_match_cflookup(char *, char *, char *, int, char **,
122 			    int *, int *);
123 extern int __yp_match_rsvdport_cflookup(char *, char *, char *, int, char **,
124 				    int *, int *);
125 extern int __yp_first_cflookup(char *, char *, char **, int *, char **,
126 			    int *, int);
127 
128 extern int __yp_next_cflookup(char *, char *, char *, int, char **, int *,
129 			    char **, int  *, int);
130 
131 extern int __yp_all_cflookup(char *, char *, struct ypall_callback *, int);
132 
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif /* _NIS_COMMON_H */
138