18040SBaban.Kenkre@Sun.COM /* 28040SBaban.Kenkre@Sun.COM * CDDL HEADER START 38040SBaban.Kenkre@Sun.COM * 48040SBaban.Kenkre@Sun.COM * The contents of this file are subject to the terms of the 58040SBaban.Kenkre@Sun.COM * Common Development and Distribution License (the "License"). 68040SBaban.Kenkre@Sun.COM * You may not use this file except in compliance with the License. 78040SBaban.Kenkre@Sun.COM * 88040SBaban.Kenkre@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 98040SBaban.Kenkre@Sun.COM * or http://www.opensolaris.org/os/licensing. 108040SBaban.Kenkre@Sun.COM * See the License for the specific language governing permissions 118040SBaban.Kenkre@Sun.COM * and limitations under the License. 128040SBaban.Kenkre@Sun.COM * 138040SBaban.Kenkre@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 148040SBaban.Kenkre@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 158040SBaban.Kenkre@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 168040SBaban.Kenkre@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 178040SBaban.Kenkre@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 188040SBaban.Kenkre@Sun.COM * 198040SBaban.Kenkre@Sun.COM * CDDL HEADER END 208040SBaban.Kenkre@Sun.COM */ 218040SBaban.Kenkre@Sun.COM /* 22*9565SJordan.Brown@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 238040SBaban.Kenkre@Sun.COM * Use is subject to license terms. 248040SBaban.Kenkre@Sun.COM */ 258040SBaban.Kenkre@Sun.COM 268040SBaban.Kenkre@Sun.COM #ifndef _AD_COMMON_H 278040SBaban.Kenkre@Sun.COM #define _AD_COMMON_H 288040SBaban.Kenkre@Sun.COM 298040SBaban.Kenkre@Sun.COM #ifdef __cplusplus 308040SBaban.Kenkre@Sun.COM extern "C" { 318040SBaban.Kenkre@Sun.COM #endif 328040SBaban.Kenkre@Sun.COM 338040SBaban.Kenkre@Sun.COM #include <ctype.h> 348040SBaban.Kenkre@Sun.COM #include <nss_dbdefs.h> 358040SBaban.Kenkre@Sun.COM #include <stdlib.h> 368040SBaban.Kenkre@Sun.COM #include <stdio.h> 378040SBaban.Kenkre@Sun.COM #include <string.h> 388040SBaban.Kenkre@Sun.COM #include <strings.h> 398040SBaban.Kenkre@Sun.COM #include <signal.h> 408040SBaban.Kenkre@Sun.COM #include <idmap.h> 418040SBaban.Kenkre@Sun.COM #include <sys/idmap.h> 42*9565SJordan.Brown@Sun.COM #include <rpcsvc/idmap_prot.h> 438040SBaban.Kenkre@Sun.COM #include <idmap_priv.h> 448040SBaban.Kenkre@Sun.COM #include "addisc.h" 458040SBaban.Kenkre@Sun.COM #include "libadutils.h" 468040SBaban.Kenkre@Sun.COM 478040SBaban.Kenkre@Sun.COM #define _GROUP "group" 488040SBaban.Kenkre@Sun.COM #define _PASSWD "passwd" 498040SBaban.Kenkre@Sun.COM #define _SHADOW "shadow" 508040SBaban.Kenkre@Sun.COM 518040SBaban.Kenkre@Sun.COM #define WK_DOMAIN "BUILTIN" 528040SBaban.Kenkre@Sun.COM #define CFG_QUEUE_MAX_SIZE 15 538040SBaban.Kenkre@Sun.COM 548040SBaban.Kenkre@Sun.COM #define SEARCHFILTERLEN 256 558040SBaban.Kenkre@Sun.COM #define RESET_ERRNO()\ 568040SBaban.Kenkre@Sun.COM if (errno == EINVAL)\ 578040SBaban.Kenkre@Sun.COM errno = 0; 588040SBaban.Kenkre@Sun.COM 598040SBaban.Kenkre@Sun.COM /* 608040SBaban.Kenkre@Sun.COM * Superset the nss_backend_t abstract data type. This ADT has 618040SBaban.Kenkre@Sun.COM * been extended to include AD associated data structures. 628040SBaban.Kenkre@Sun.COM */ 638040SBaban.Kenkre@Sun.COM 648040SBaban.Kenkre@Sun.COM typedef struct ad_backend *ad_backend_ptr; 658040SBaban.Kenkre@Sun.COM typedef nss_status_t (*ad_backend_op_t)(ad_backend_ptr, void *); 668040SBaban.Kenkre@Sun.COM typedef int (*fnf)(ad_backend_ptr be, nss_XbyY_args_t *argp); 678040SBaban.Kenkre@Sun.COM 688040SBaban.Kenkre@Sun.COM typedef enum { 698040SBaban.Kenkre@Sun.COM NSS_AD_DB_NONE = 0, 708040SBaban.Kenkre@Sun.COM NSS_AD_DB_PASSWD_BYNAME = 1, 718040SBaban.Kenkre@Sun.COM NSS_AD_DB_PASSWD_BYUID = 2, 728040SBaban.Kenkre@Sun.COM NSS_AD_DB_GROUP_BYNAME = 3, 738040SBaban.Kenkre@Sun.COM NSS_AD_DB_GROUP_BYGID = 4, 748040SBaban.Kenkre@Sun.COM NSS_AD_DB_SHADOW_BYNAME = 5 758040SBaban.Kenkre@Sun.COM } nss_ad_db_type_t; 768040SBaban.Kenkre@Sun.COM 778040SBaban.Kenkre@Sun.COM struct ad_backend { 788040SBaban.Kenkre@Sun.COM ad_backend_op_t *ops; 798040SBaban.Kenkre@Sun.COM nss_dbop_t nops; 808040SBaban.Kenkre@Sun.COM char *tablename; 818040SBaban.Kenkre@Sun.COM const char **attrs; 828040SBaban.Kenkre@Sun.COM fnf adobj2str; 838040SBaban.Kenkre@Sun.COM char *buffer; 848040SBaban.Kenkre@Sun.COM int buflen; 858040SBaban.Kenkre@Sun.COM idmap_handle_t *ih; 868040SBaban.Kenkre@Sun.COM uid_t uid; 878040SBaban.Kenkre@Sun.COM adutils_result_t *result; 888040SBaban.Kenkre@Sun.COM nss_ad_db_type_t db_type; 898040SBaban.Kenkre@Sun.COM }; 908040SBaban.Kenkre@Sun.COM 918040SBaban.Kenkre@Sun.COM typedef struct nssad_prop { 928040SBaban.Kenkre@Sun.COM char *domain_name; 938040SBaban.Kenkre@Sun.COM idmap_ad_disc_ds_t *domain_controller; 948040SBaban.Kenkre@Sun.COM } nssad_prop_t; 958040SBaban.Kenkre@Sun.COM 968040SBaban.Kenkre@Sun.COM typedef struct nssad_cfg { 978040SBaban.Kenkre@Sun.COM pthread_rwlock_t lock; 988040SBaban.Kenkre@Sun.COM nssad_prop_t props; 998040SBaban.Kenkre@Sun.COM ad_disc_t ad_ctx; 1008040SBaban.Kenkre@Sun.COM adutils_ad_t *ad; 1018040SBaban.Kenkre@Sun.COM struct nssad_cfg *qnext; 1028040SBaban.Kenkre@Sun.COM } nssad_cfg_t; 1038040SBaban.Kenkre@Sun.COM 1048040SBaban.Kenkre@Sun.COM typedef struct nssad_state { 1058040SBaban.Kenkre@Sun.COM nssad_cfg_t *qhead; 1068040SBaban.Kenkre@Sun.COM nssad_cfg_t *qtail; 1078040SBaban.Kenkre@Sun.COM uint32_t qcount; 1088040SBaban.Kenkre@Sun.COM } nssad_state_t; 1098040SBaban.Kenkre@Sun.COM 1108040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_destr(ad_backend_ptr be, void *a); 1118040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_endent(ad_backend_ptr be, void *a); 1128040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_setent(ad_backend_ptr be, void *a); 1138040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_getent(ad_backend_ptr be, void *a); 1148040SBaban.Kenkre@Sun.COM nss_backend_t *_nss_ad_constr(ad_backend_op_t ops[], int nops, 1158040SBaban.Kenkre@Sun.COM char *tablename, const char **attrs, fnf ldapobj2str); 1168040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_lookup(ad_backend_ptr be, 1178040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp, const char *database, 1188040SBaban.Kenkre@Sun.COM const char *searchfilter, const char *dname, 1198040SBaban.Kenkre@Sun.COM int *try_idmap); 1208040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_marshall_data(ad_backend_ptr be, 1218040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp); 1228040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_sanitize_status(ad_backend_ptr be, 1238040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp, nss_status_t stat); 1248040SBaban.Kenkre@Sun.COM extern int _ldap_filter_name(char *filter_name, const char *name, 1258040SBaban.Kenkre@Sun.COM int filter_name_size); 1268040SBaban.Kenkre@Sun.COM 1278040SBaban.Kenkre@Sun.COM 1288040SBaban.Kenkre@Sun.COM #ifdef __cplusplus 1298040SBaban.Kenkre@Sun.COM } 1308040SBaban.Kenkre@Sun.COM #endif 1318040SBaban.Kenkre@Sun.COM 1328040SBaban.Kenkre@Sun.COM #endif /* _AD_COMMON_H */ 133