xref: /onnv-gate/usr/src/lib/nsswitch/nis/common/nis_common.h (revision 8040:42abce45ef67)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52830Sdjl  * Common Development and Distribution License (the "License").
62830Sdjl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
216812Sraf 
220Sstevel@tonic-gate /*
236812Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate  * nis_common.h
290Sstevel@tonic-gate  *
300Sstevel@tonic-gate  * Common code and structures used by name-service-switch "nis" backends.
310Sstevel@tonic-gate  */
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #ifndef _NIS_COMMON_H
340Sstevel@tonic-gate #define	_NIS_COMMON_H
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #include <nss_dbdefs.h>
37*8040SBaban.Kenkre@Sun.COM #include <stdlib.h>
38*8040SBaban.Kenkre@Sun.COM #include <strings.h>
390Sstevel@tonic-gate #include <signal.h>
400Sstevel@tonic-gate #include <rpcsvc/ypclnt.h>
410Sstevel@tonic-gate #include <rpcsvc/yp_prot.h>
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #ifdef	__cplusplus
440Sstevel@tonic-gate extern "C" {
450Sstevel@tonic-gate #endif
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #define	NIS_MAP_AUDITUSER	"audit_user"
480Sstevel@tonic-gate #define	NIS_MAP_AUTHATTR	"auth_attr"
490Sstevel@tonic-gate #define	NIS_MAP_EXECATTR	"exec_attr"
500Sstevel@tonic-gate #define	NIS_MAP_PROFATTR	"prof_attr"
510Sstevel@tonic-gate #define	NIS_MAP_USERATTR	"user_attr"
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 
540Sstevel@tonic-gate typedef struct nis_backend *nis_backend_ptr_t;
550Sstevel@tonic-gate typedef nss_status_t	(*nis_backend_op_t)(nis_backend_ptr_t, void *);
560Sstevel@tonic-gate 
570Sstevel@tonic-gate struct nis_backend {
580Sstevel@tonic-gate 	nis_backend_op_t	*ops;
590Sstevel@tonic-gate 	nss_dbop_t		n_ops;
600Sstevel@tonic-gate 	const char		*domain;
610Sstevel@tonic-gate 	const char		*enum_map;
620Sstevel@tonic-gate 	char			*enum_key;
630Sstevel@tonic-gate 	int			enum_keylen;
640Sstevel@tonic-gate };
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
670Sstevel@tonic-gate  * Iterator function for _nss_nis_do_all(), which probably calls yp_all().
680Sstevel@tonic-gate  *   NSS_NOTFOUND means "keep enumerating", NSS_SUCCESS means"return now",
690Sstevel@tonic-gate  *   other values don't make much sense.  In other words we're abusing
700Sstevel@tonic-gate  *   (overloading) the meaning of nss_status_t, but hey...
710Sstevel@tonic-gate  * _nss_nis_XY_all() is a wrapper around _nss_nis_do_all() that does the
720Sstevel@tonic-gate  *   generic work for nss_XbyY_args_t backends (calls cstr2ent etc).
730Sstevel@tonic-gate  */
740Sstevel@tonic-gate typedef nss_status_t	(*nis_do_all_func_t)(const char *, int, void *priv);
750Sstevel@tonic-gate typedef int		(*nis_XY_check_func)(nss_XbyY_args_t *);
760Sstevel@tonic-gate 
770Sstevel@tonic-gate extern nss_backend_t	*_nss_nis_constr(nis_backend_op_t	*ops,
780Sstevel@tonic-gate 					int			n_ops,
790Sstevel@tonic-gate 					const char		*map);
800Sstevel@tonic-gate extern nss_status_t	_nss_nis_destr(nis_backend_ptr_t, void *dummy);
810Sstevel@tonic-gate extern nss_status_t	_nss_nis_setent(nis_backend_ptr_t, void *dummy);
820Sstevel@tonic-gate extern nss_status_t  	_nss_nis_endent(nis_backend_ptr_t, void *dummy);
830Sstevel@tonic-gate extern nss_status_t  	_nss_nis_getent_rigid(nis_backend_ptr_t, void *);
840Sstevel@tonic-gate extern nss_status_t  	_nss_nis_getent_netdb(nis_backend_ptr_t, void *);
850Sstevel@tonic-gate extern nss_status_t 	_nss_nis_do_all(nis_backend_ptr_t,
860Sstevel@tonic-gate 					void			*func_priv,
870Sstevel@tonic-gate 					const char		*filter,
880Sstevel@tonic-gate 					nis_do_all_func_t	func);
890Sstevel@tonic-gate extern nss_status_t 	_nss_nis_XY_all(nis_backend_ptr_t,
900Sstevel@tonic-gate 					nss_XbyY_args_t		*check_args,
910Sstevel@tonic-gate 					int			netdb,
920Sstevel@tonic-gate 					const char		*filter,
930Sstevel@tonic-gate 					nis_XY_check_func	check);
940Sstevel@tonic-gate extern nss_status_t	_nss_nis_lookup(nis_backend_ptr_t,
950Sstevel@tonic-gate 					nss_XbyY_args_t		*args,
960Sstevel@tonic-gate 					int			netdb,
970Sstevel@tonic-gate 					const char		*map,
980Sstevel@tonic-gate 					const char		*key,
990Sstevel@tonic-gate 					int			*yp_statusp);
1000Sstevel@tonic-gate extern nss_status_t _nss_nis_lookup_rsvdport(nis_backend_ptr_t   be,
1010Sstevel@tonic-gate 					nss_XbyY_args_t	*args,
1020Sstevel@tonic-gate 					int netdb,
1030Sstevel@tonic-gate 					const char	*map,
1040Sstevel@tonic-gate 					const char	*key,
1050Sstevel@tonic-gate 					int	*ypstatusp);
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate /* Lower-level interface */
1080Sstevel@tonic-gate extern nss_status_t	_nss_nis_ypmatch(const char		*domain,
1090Sstevel@tonic-gate 					const char		*map,
1100Sstevel@tonic-gate 					const char		*key,
1110Sstevel@tonic-gate 					char			**valp,
1120Sstevel@tonic-gate 					int			*vallenp,
1130Sstevel@tonic-gate 					int			*yp_statusp);
1140Sstevel@tonic-gate extern const char	*_nss_nis_domain();
1150Sstevel@tonic-gate extern int __nss2herrno(nss_status_t nsstat);
1166812Sraf extern int thr_sigsetmask(int how, const sigset_t *set, sigset_t *oset);
1172830Sdjl extern int _nss_nis_check_name_aliases(nss_XbyY_args_t *argp,
1182830Sdjl 					const char *line,
1192830Sdjl 					int linelen);
1200Sstevel@tonic-gate 
1210Sstevel@tonic-gate /* private yp "configurable lookup persistence" interface in libnsl */
1220Sstevel@tonic-gate extern int __yp_match_cflookup(char *, char *, char *, int, char **,
1230Sstevel@tonic-gate 			    int *, int *);
1240Sstevel@tonic-gate extern int __yp_match_rsvdport_cflookup(char *, char *, char *, int, char **,
1250Sstevel@tonic-gate 				    int *, int *);
1260Sstevel@tonic-gate extern int __yp_first_cflookup(char *, char *, char **, int *, char **,
1270Sstevel@tonic-gate 			    int *, int);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate extern int __yp_next_cflookup(char *, char *, char *, int, char **, int *,
1300Sstevel@tonic-gate 			    char **, int  *, int);
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate extern int __yp_all_cflookup(char *, char *, struct ypall_callback *, int);
1330Sstevel@tonic-gate 
134*8040SBaban.Kenkre@Sun.COM /* functions to validate passwd and group ids */
135*8040SBaban.Kenkre@Sun.COM extern int validate_passwd_ids(char **linepp, int *linelenp, int allocbuf);
136*8040SBaban.Kenkre@Sun.COM extern int validate_group_ids(char **linepp, int *linelenp, int allocbuf);
137*8040SBaban.Kenkre@Sun.COM 
1380Sstevel@tonic-gate #ifdef	__cplusplus
1390Sstevel@tonic-gate }
1400Sstevel@tonic-gate #endif
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate #endif /* _NIS_COMMON_H */
143