1*8040SBaban.Kenkre@Sun.COM /* 2*8040SBaban.Kenkre@Sun.COM * CDDL HEADER START 3*8040SBaban.Kenkre@Sun.COM * 4*8040SBaban.Kenkre@Sun.COM * The contents of this file are subject to the terms of the 5*8040SBaban.Kenkre@Sun.COM * Common Development and Distribution License (the "License"). 6*8040SBaban.Kenkre@Sun.COM * You may not use this file except in compliance with the License. 7*8040SBaban.Kenkre@Sun.COM * 8*8040SBaban.Kenkre@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*8040SBaban.Kenkre@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*8040SBaban.Kenkre@Sun.COM * See the License for the specific language governing permissions 11*8040SBaban.Kenkre@Sun.COM * and limitations under the License. 12*8040SBaban.Kenkre@Sun.COM * 13*8040SBaban.Kenkre@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*8040SBaban.Kenkre@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*8040SBaban.Kenkre@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*8040SBaban.Kenkre@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*8040SBaban.Kenkre@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*8040SBaban.Kenkre@Sun.COM * 19*8040SBaban.Kenkre@Sun.COM * CDDL HEADER END 20*8040SBaban.Kenkre@Sun.COM */ 21*8040SBaban.Kenkre@Sun.COM /* 22*8040SBaban.Kenkre@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*8040SBaban.Kenkre@Sun.COM * Use is subject to license terms. 24*8040SBaban.Kenkre@Sun.COM */ 25*8040SBaban.Kenkre@Sun.COM 26*8040SBaban.Kenkre@Sun.COM #ifndef _AD_COMMON_H 27*8040SBaban.Kenkre@Sun.COM #define _AD_COMMON_H 28*8040SBaban.Kenkre@Sun.COM 29*8040SBaban.Kenkre@Sun.COM #ifdef __cplusplus 30*8040SBaban.Kenkre@Sun.COM extern "C" { 31*8040SBaban.Kenkre@Sun.COM #endif 32*8040SBaban.Kenkre@Sun.COM 33*8040SBaban.Kenkre@Sun.COM #include <ctype.h> 34*8040SBaban.Kenkre@Sun.COM #include <nss_dbdefs.h> 35*8040SBaban.Kenkre@Sun.COM #include <stdlib.h> 36*8040SBaban.Kenkre@Sun.COM #include <stdio.h> 37*8040SBaban.Kenkre@Sun.COM #include <string.h> 38*8040SBaban.Kenkre@Sun.COM #include <strings.h> 39*8040SBaban.Kenkre@Sun.COM #include <signal.h> 40*8040SBaban.Kenkre@Sun.COM #include <idmap.h> 41*8040SBaban.Kenkre@Sun.COM #include <sys/idmap.h> 42*8040SBaban.Kenkre@Sun.COM #include <idmap_prot.h> 43*8040SBaban.Kenkre@Sun.COM #include <idmap_priv.h> 44*8040SBaban.Kenkre@Sun.COM #include "addisc.h" 45*8040SBaban.Kenkre@Sun.COM #include "libadutils.h" 46*8040SBaban.Kenkre@Sun.COM 47*8040SBaban.Kenkre@Sun.COM #define _GROUP "group" 48*8040SBaban.Kenkre@Sun.COM #define _PASSWD "passwd" 49*8040SBaban.Kenkre@Sun.COM #define _SHADOW "shadow" 50*8040SBaban.Kenkre@Sun.COM 51*8040SBaban.Kenkre@Sun.COM #define WK_DOMAIN "BUILTIN" 52*8040SBaban.Kenkre@Sun.COM #define CFG_QUEUE_MAX_SIZE 15 53*8040SBaban.Kenkre@Sun.COM 54*8040SBaban.Kenkre@Sun.COM #define SEARCHFILTERLEN 256 55*8040SBaban.Kenkre@Sun.COM #define RESET_ERRNO()\ 56*8040SBaban.Kenkre@Sun.COM if (errno == EINVAL)\ 57*8040SBaban.Kenkre@Sun.COM errno = 0; 58*8040SBaban.Kenkre@Sun.COM 59*8040SBaban.Kenkre@Sun.COM /* 60*8040SBaban.Kenkre@Sun.COM * Superset the nss_backend_t abstract data type. This ADT has 61*8040SBaban.Kenkre@Sun.COM * been extended to include AD associated data structures. 62*8040SBaban.Kenkre@Sun.COM */ 63*8040SBaban.Kenkre@Sun.COM 64*8040SBaban.Kenkre@Sun.COM typedef struct ad_backend *ad_backend_ptr; 65*8040SBaban.Kenkre@Sun.COM typedef nss_status_t (*ad_backend_op_t)(ad_backend_ptr, void *); 66*8040SBaban.Kenkre@Sun.COM typedef int (*fnf)(ad_backend_ptr be, nss_XbyY_args_t *argp); 67*8040SBaban.Kenkre@Sun.COM 68*8040SBaban.Kenkre@Sun.COM typedef enum { 69*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_NONE = 0, 70*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_PASSWD_BYNAME = 1, 71*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_PASSWD_BYUID = 2, 72*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_GROUP_BYNAME = 3, 73*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_GROUP_BYGID = 4, 74*8040SBaban.Kenkre@Sun.COM NSS_AD_DB_SHADOW_BYNAME = 5 75*8040SBaban.Kenkre@Sun.COM } nss_ad_db_type_t; 76*8040SBaban.Kenkre@Sun.COM 77*8040SBaban.Kenkre@Sun.COM struct ad_backend { 78*8040SBaban.Kenkre@Sun.COM ad_backend_op_t *ops; 79*8040SBaban.Kenkre@Sun.COM nss_dbop_t nops; 80*8040SBaban.Kenkre@Sun.COM char *tablename; 81*8040SBaban.Kenkre@Sun.COM const char **attrs; 82*8040SBaban.Kenkre@Sun.COM fnf adobj2str; 83*8040SBaban.Kenkre@Sun.COM char *buffer; 84*8040SBaban.Kenkre@Sun.COM int buflen; 85*8040SBaban.Kenkre@Sun.COM idmap_handle_t *ih; 86*8040SBaban.Kenkre@Sun.COM uid_t uid; 87*8040SBaban.Kenkre@Sun.COM adutils_result_t *result; 88*8040SBaban.Kenkre@Sun.COM nss_ad_db_type_t db_type; 89*8040SBaban.Kenkre@Sun.COM }; 90*8040SBaban.Kenkre@Sun.COM 91*8040SBaban.Kenkre@Sun.COM typedef struct nssad_prop { 92*8040SBaban.Kenkre@Sun.COM char *domain_name; 93*8040SBaban.Kenkre@Sun.COM idmap_ad_disc_ds_t *domain_controller; 94*8040SBaban.Kenkre@Sun.COM } nssad_prop_t; 95*8040SBaban.Kenkre@Sun.COM 96*8040SBaban.Kenkre@Sun.COM typedef struct nssad_cfg { 97*8040SBaban.Kenkre@Sun.COM pthread_rwlock_t lock; 98*8040SBaban.Kenkre@Sun.COM nssad_prop_t props; 99*8040SBaban.Kenkre@Sun.COM ad_disc_t ad_ctx; 100*8040SBaban.Kenkre@Sun.COM adutils_ad_t *ad; 101*8040SBaban.Kenkre@Sun.COM struct nssad_cfg *qnext; 102*8040SBaban.Kenkre@Sun.COM } nssad_cfg_t; 103*8040SBaban.Kenkre@Sun.COM 104*8040SBaban.Kenkre@Sun.COM typedef struct nssad_state { 105*8040SBaban.Kenkre@Sun.COM nssad_cfg_t *qhead; 106*8040SBaban.Kenkre@Sun.COM nssad_cfg_t *qtail; 107*8040SBaban.Kenkre@Sun.COM uint32_t qcount; 108*8040SBaban.Kenkre@Sun.COM } nssad_state_t; 109*8040SBaban.Kenkre@Sun.COM 110*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_destr(ad_backend_ptr be, void *a); 111*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_endent(ad_backend_ptr be, void *a); 112*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_setent(ad_backend_ptr be, void *a); 113*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_getent(ad_backend_ptr be, void *a); 114*8040SBaban.Kenkre@Sun.COM nss_backend_t *_nss_ad_constr(ad_backend_op_t ops[], int nops, 115*8040SBaban.Kenkre@Sun.COM char *tablename, const char **attrs, fnf ldapobj2str); 116*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_lookup(ad_backend_ptr be, 117*8040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp, const char *database, 118*8040SBaban.Kenkre@Sun.COM const char *searchfilter, const char *dname, 119*8040SBaban.Kenkre@Sun.COM int *try_idmap); 120*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_marshall_data(ad_backend_ptr be, 121*8040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp); 122*8040SBaban.Kenkre@Sun.COM extern nss_status_t _nss_ad_sanitize_status(ad_backend_ptr be, 123*8040SBaban.Kenkre@Sun.COM nss_XbyY_args_t *argp, nss_status_t stat); 124*8040SBaban.Kenkre@Sun.COM extern int _ldap_filter_name(char *filter_name, const char *name, 125*8040SBaban.Kenkre@Sun.COM int filter_name_size); 126*8040SBaban.Kenkre@Sun.COM 127*8040SBaban.Kenkre@Sun.COM 128*8040SBaban.Kenkre@Sun.COM #ifdef __cplusplus 129*8040SBaban.Kenkre@Sun.COM } 130*8040SBaban.Kenkre@Sun.COM #endif 131*8040SBaban.Kenkre@Sun.COM 132*8040SBaban.Kenkre@Sun.COM #endif /* _AD_COMMON_H */ 133