xref: /titanic_44/usr/src/lib/nsswitch/ad/common/ad_common.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
12b4a7802SBaban Kenkre /*
22b4a7802SBaban Kenkre  * CDDL HEADER START
32b4a7802SBaban Kenkre  *
42b4a7802SBaban Kenkre  * The contents of this file are subject to the terms of the
52b4a7802SBaban Kenkre  * Common Development and Distribution License (the "License").
62b4a7802SBaban Kenkre  * You may not use this file except in compliance with the License.
72b4a7802SBaban Kenkre  *
82b4a7802SBaban Kenkre  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92b4a7802SBaban Kenkre  * or http://www.opensolaris.org/os/licensing.
102b4a7802SBaban Kenkre  * See the License for the specific language governing permissions
112b4a7802SBaban Kenkre  * and limitations under the License.
122b4a7802SBaban Kenkre  *
132b4a7802SBaban Kenkre  * When distributing Covered Code, include this CDDL HEADER in each
142b4a7802SBaban Kenkre  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152b4a7802SBaban Kenkre  * If applicable, add the following below this CDDL HEADER, with the
162b4a7802SBaban Kenkre  * fields enclosed by brackets "[]" replaced with your own identifying
172b4a7802SBaban Kenkre  * information: Portions Copyright [yyyy] [name of copyright owner]
182b4a7802SBaban Kenkre  *
192b4a7802SBaban Kenkre  * CDDL HEADER END
202b4a7802SBaban Kenkre  */
212b4a7802SBaban Kenkre /*
22*1fdeec65Sjoyce mcintosh  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
232b4a7802SBaban Kenkre  */
242b4a7802SBaban Kenkre 
252b4a7802SBaban Kenkre #ifndef	_AD_COMMON_H
262b4a7802SBaban Kenkre #define	_AD_COMMON_H
272b4a7802SBaban Kenkre 
282b4a7802SBaban Kenkre #ifdef	__cplusplus
292b4a7802SBaban Kenkre extern "C" {
302b4a7802SBaban Kenkre #endif
312b4a7802SBaban Kenkre 
322b4a7802SBaban Kenkre #include <ctype.h>
332b4a7802SBaban Kenkre #include <nss_dbdefs.h>
342b4a7802SBaban Kenkre #include <stdlib.h>
352b4a7802SBaban Kenkre #include <stdio.h>
362b4a7802SBaban Kenkre #include <string.h>
372b4a7802SBaban Kenkre #include <strings.h>
382b4a7802SBaban Kenkre #include <signal.h>
392b4a7802SBaban Kenkre #include <idmap.h>
402b4a7802SBaban Kenkre #include <sys/idmap.h>
419b214d32SJordan Brown #include <rpcsvc/idmap_prot.h>
422b4a7802SBaban Kenkre #include <idmap_priv.h>
432b4a7802SBaban Kenkre #include "addisc.h"
442b4a7802SBaban Kenkre #include "libadutils.h"
452b4a7802SBaban Kenkre 
462b4a7802SBaban Kenkre #define	_GROUP	"group"
472b4a7802SBaban Kenkre #define	_PASSWD	"passwd"
482b4a7802SBaban Kenkre #define	_SHADOW	"shadow"
492b4a7802SBaban Kenkre 
502b4a7802SBaban Kenkre #define	WK_DOMAIN	"BUILTIN"
512b4a7802SBaban Kenkre #define	CFG_QUEUE_MAX_SIZE	15
522b4a7802SBaban Kenkre 
532b4a7802SBaban Kenkre #define	SEARCHFILTERLEN		256
542b4a7802SBaban Kenkre #define	RESET_ERRNO()\
552b4a7802SBaban Kenkre 	if (errno == EINVAL)\
562b4a7802SBaban Kenkre 		errno = 0;
572b4a7802SBaban Kenkre 
582b4a7802SBaban Kenkre /*
592b4a7802SBaban Kenkre  * Superset the nss_backend_t abstract data type. This ADT has
602b4a7802SBaban Kenkre  * been extended to include AD associated data structures.
612b4a7802SBaban Kenkre  */
622b4a7802SBaban Kenkre 
632b4a7802SBaban Kenkre typedef struct ad_backend *ad_backend_ptr;
642b4a7802SBaban Kenkre typedef nss_status_t (*ad_backend_op_t)(ad_backend_ptr, void *);
652b4a7802SBaban Kenkre typedef int (*fnf)(ad_backend_ptr be, nss_XbyY_args_t *argp);
662b4a7802SBaban Kenkre 
672b4a7802SBaban Kenkre typedef enum {
682b4a7802SBaban Kenkre 	NSS_AD_DB_NONE		= 0,
692b4a7802SBaban Kenkre 	NSS_AD_DB_PASSWD_BYNAME	= 1,
702b4a7802SBaban Kenkre 	NSS_AD_DB_PASSWD_BYUID	= 2,
712b4a7802SBaban Kenkre 	NSS_AD_DB_GROUP_BYNAME	= 3,
722b4a7802SBaban Kenkre 	NSS_AD_DB_GROUP_BYGID	= 4,
732b4a7802SBaban Kenkre 	NSS_AD_DB_SHADOW_BYNAME	= 5
742b4a7802SBaban Kenkre } nss_ad_db_type_t;
752b4a7802SBaban Kenkre 
762b4a7802SBaban Kenkre struct ad_backend {
772b4a7802SBaban Kenkre 	ad_backend_op_t		*ops;
782b4a7802SBaban Kenkre 	nss_dbop_t		nops;
792b4a7802SBaban Kenkre 	char			*tablename;
802b4a7802SBaban Kenkre 	const char		**attrs;
812b4a7802SBaban Kenkre 	fnf			adobj2str;
822b4a7802SBaban Kenkre 	char			*buffer;
832b4a7802SBaban Kenkre 	int			buflen;
842b4a7802SBaban Kenkre 	uid_t			uid;
852b4a7802SBaban Kenkre 	adutils_result_t	*result;
862b4a7802SBaban Kenkre 	nss_ad_db_type_t	db_type;
872b4a7802SBaban Kenkre };
882b4a7802SBaban Kenkre 
892b4a7802SBaban Kenkre typedef struct nssad_prop {
902b4a7802SBaban Kenkre 	char			*domain_name;
912b4a7802SBaban Kenkre 	idmap_ad_disc_ds_t	*domain_controller;
922b4a7802SBaban Kenkre } nssad_prop_t;
932b4a7802SBaban Kenkre 
942b4a7802SBaban Kenkre typedef struct nssad_cfg {
952b4a7802SBaban Kenkre 	pthread_rwlock_t	lock;
962b4a7802SBaban Kenkre 	nssad_prop_t		props;
972b4a7802SBaban Kenkre 	ad_disc_t		ad_ctx;
982b4a7802SBaban Kenkre 	adutils_ad_t		*ad;
992b4a7802SBaban Kenkre 	struct nssad_cfg	*qnext;
1002b4a7802SBaban Kenkre } nssad_cfg_t;
1012b4a7802SBaban Kenkre 
1022b4a7802SBaban Kenkre typedef struct nssad_state {
1032b4a7802SBaban Kenkre 	nssad_cfg_t		*qhead;
1042b4a7802SBaban Kenkre 	nssad_cfg_t		*qtail;
1052b4a7802SBaban Kenkre 	uint32_t		qcount;
1062b4a7802SBaban Kenkre } nssad_state_t;
1072b4a7802SBaban Kenkre 
1082b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_destr(ad_backend_ptr be, void *a);
1092b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_endent(ad_backend_ptr be, void *a);
1102b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_setent(ad_backend_ptr be, void *a);
1112b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_getent(ad_backend_ptr be, void *a);
1122b4a7802SBaban Kenkre nss_backend_t		*_nss_ad_constr(ad_backend_op_t ops[], int nops,
1132b4a7802SBaban Kenkre 			char *tablename, const char **attrs, fnf ldapobj2str);
1142b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_lookup(ad_backend_ptr be,
1152b4a7802SBaban Kenkre 			nss_XbyY_args_t *argp, const char *database,
1162b4a7802SBaban Kenkre 			const char *searchfilter, const char *dname,
1172b4a7802SBaban Kenkre 			int *try_idmap);
1182b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_marshall_data(ad_backend_ptr be,
1192b4a7802SBaban Kenkre 			nss_XbyY_args_t *argp);
1202b4a7802SBaban Kenkre extern nss_status_t	_nss_ad_sanitize_status(ad_backend_ptr be,
1212b4a7802SBaban Kenkre 			nss_XbyY_args_t *argp, nss_status_t stat);
1222b4a7802SBaban Kenkre extern int		_ldap_filter_name(char *filter_name, const char *name,
1232b4a7802SBaban Kenkre 			int filter_name_size);
1242b4a7802SBaban Kenkre 
1252b4a7802SBaban Kenkre 
1262b4a7802SBaban Kenkre #ifdef	__cplusplus
1272b4a7802SBaban Kenkre }
1282b4a7802SBaban Kenkre #endif
1292b4a7802SBaban Kenkre 
1302b4a7802SBaban Kenkre #endif	/* _AD_COMMON_H */
131