1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _LDAP_COMMON_H 28*0Sstevel@tonic-gate #define _LDAP_COMMON_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <ctype.h> 37*0Sstevel@tonic-gate #include <nss_dbdefs.h> 38*0Sstevel@tonic-gate #include <stdlib.h> 39*0Sstevel@tonic-gate #include <string.h> 40*0Sstevel@tonic-gate #include <strings.h> 41*0Sstevel@tonic-gate #include <signal.h> 42*0Sstevel@tonic-gate #include <lber.h> 43*0Sstevel@tonic-gate #include <ldap.h> 44*0Sstevel@tonic-gate #include <pwd.h> 45*0Sstevel@tonic-gate #include "ns_sldap.h" 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate #define _ALIASES "aliases" 48*0Sstevel@tonic-gate #define _AUTOMOUNT "automount" 49*0Sstevel@tonic-gate #define _AUTHATTR "auth_attr" 50*0Sstevel@tonic-gate #define _AUUSER "audit_user" 51*0Sstevel@tonic-gate #define _BOOTPARAMS "bootparams" 52*0Sstevel@tonic-gate #define _DEFAULT "default" 53*0Sstevel@tonic-gate #define _ETHERS "ethers" 54*0Sstevel@tonic-gate #define _EXECATTR "exec_attr" 55*0Sstevel@tonic-gate #define _GROUP "group" 56*0Sstevel@tonic-gate #define _PROJECT "project" 57*0Sstevel@tonic-gate #define _HOSTS "hosts" 58*0Sstevel@tonic-gate #define _HOSTS6 "hosts" 59*0Sstevel@tonic-gate #define _NETGROUP "netgroup" 60*0Sstevel@tonic-gate #define _NETMASKS "netmasks" 61*0Sstevel@tonic-gate #define _NETWORKS "networks" 62*0Sstevel@tonic-gate #define _PASSWD "passwd" 63*0Sstevel@tonic-gate #define _PRINTERS "printers" 64*0Sstevel@tonic-gate #define _PROFATTR "prof_attr" 65*0Sstevel@tonic-gate #define _PROTOCOLS "protocols" 66*0Sstevel@tonic-gate #define _PUBLICKEY "publickey" 67*0Sstevel@tonic-gate #define _RPC "rpc" 68*0Sstevel@tonic-gate #define _SERVICES "services" 69*0Sstevel@tonic-gate #define _SHADOW "shadow" 70*0Sstevel@tonic-gate #define _USERATTR "user_attr" 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate #define NSS_STR_PARSE_NO_ADDR (NSS_STR_PARSE_ERANGE + 100) 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate #define DOTTEDSUBDOMAIN(string) \ 75*0Sstevel@tonic-gate ((string != NULL) && (strchr(string, '.') != NULL)) 76*0Sstevel@tonic-gate #define SEARCHFILTERLEN 256 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* 79*0Sstevel@tonic-gate * Superset the nss_backend_t abstract data type. This ADT has 80*0Sstevel@tonic-gate * been extended to include ldap associated data structures. 81*0Sstevel@tonic-gate */ 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate typedef struct ldap_backend *ldap_backend_ptr; 84*0Sstevel@tonic-gate typedef nss_status_t (*ldap_backend_op_t)(ldap_backend_ptr, void *); 85*0Sstevel@tonic-gate typedef int (*fnf)(ldap_backend_ptr be, nss_XbyY_args_t *argp); 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate struct ldap_backend { 88*0Sstevel@tonic-gate ldap_backend_op_t *ops; 89*0Sstevel@tonic-gate nss_dbop_t nops; 90*0Sstevel@tonic-gate char *tablename; 91*0Sstevel@tonic-gate void *enumcookie; 92*0Sstevel@tonic-gate char *filter; 93*0Sstevel@tonic-gate int setcalled; 94*0Sstevel@tonic-gate const char **attrs; 95*0Sstevel@tonic-gate ns_ldap_result_t *result; 96*0Sstevel@tonic-gate fnf ldapobj2ent; 97*0Sstevel@tonic-gate void *netgroup_cookie; 98*0Sstevel@tonic-gate void *services_cookie; 99*0Sstevel@tonic-gate char *toglue; 100*0Sstevel@tonic-gate }; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_destr(ldap_backend_ptr be, void *a); 103*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_endent(ldap_backend_ptr be, void *a); 104*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_setent(ldap_backend_ptr be, void *a); 105*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_getent(ldap_backend_ptr be, void *a); 106*0Sstevel@tonic-gate nss_backend_t *_nss_ldap_constr(ldap_backend_op_t ops[], int nops, 107*0Sstevel@tonic-gate char *tablename, const char **attrs, fnf ldapobj2ent); 108*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_nocb_lookup(ldap_backend_ptr be, 109*0Sstevel@tonic-gate nss_XbyY_args_t *argp, char *database, 110*0Sstevel@tonic-gate char *searchfilter, char *domain, 111*0Sstevel@tonic-gate int (*init_filter_cb)( 112*0Sstevel@tonic-gate const ns_ldap_search_desc_t *desc, 113*0Sstevel@tonic-gate char **realfilter, const void *userdata), 114*0Sstevel@tonic-gate const void *userdata); 115*0Sstevel@tonic-gate extern nss_status_t _nss_ldap_lookup(ldap_backend_ptr be, 116*0Sstevel@tonic-gate nss_XbyY_args_t *argp, char *database, 117*0Sstevel@tonic-gate char *searchfilter, char *domain, 118*0Sstevel@tonic-gate int (*init_filter_cb)( 119*0Sstevel@tonic-gate const ns_ldap_search_desc_t *desc, 120*0Sstevel@tonic-gate char **realfilter, const void *userdata), 121*0Sstevel@tonic-gate const void *userdata); 122*0Sstevel@tonic-gate extern void _clean_ldap_backend(ldap_backend_ptr be); 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate extern ns_ldap_attr_t *getattr(ns_ldap_result_t *result, int i); 125*0Sstevel@tonic-gate extern const char *_strip_quotes(char *ipaddress); 126*0Sstevel@tonic-gate extern int __nss2herrno(nss_status_t nsstat); 127*0Sstevel@tonic-gate extern int propersubdomain(char *domain, char *subdomain); 128*0Sstevel@tonic-gate extern int chophostdomain(char *string, char *host, char *domain); 129*0Sstevel@tonic-gate extern char *_get_domain_name(char *cdn); 130*0Sstevel@tonic-gate extern int _merge_SSD_filter(const ns_ldap_search_desc_t *desc, 131*0Sstevel@tonic-gate char **realfilter, const void *userdata); 132*0Sstevel@tonic-gate extern int _ldap_filter_name(char *filter_name, const char *name, 133*0Sstevel@tonic-gate int filter_name_size); 134*0Sstevel@tonic-gate extern nss_status_t switch_err(int rc, ns_ldap_error_t *error); 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate extern void _nss_services_cookie_free(void **cookieP); 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate #ifdef DEBUG 139*0Sstevel@tonic-gate extern int printresult(ns_ldap_result_t *result); 140*0Sstevel@tonic-gate #endif /* DEBUG */ 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate #ifdef __cplusplus 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate #endif 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate #endif /* _LDAP_COMMON_H */ 147