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 5*1676Sjpk * Common Development and Distribution License (the "License"). 6*1676Sjpk * 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 */ 210Sstevel@tonic-gate /* 22*1676Sjpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _LDAP_COMMON_H 270Sstevel@tonic-gate #define _LDAP_COMMON_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <ctype.h> 360Sstevel@tonic-gate #include <nss_dbdefs.h> 370Sstevel@tonic-gate #include <stdlib.h> 380Sstevel@tonic-gate #include <string.h> 390Sstevel@tonic-gate #include <strings.h> 400Sstevel@tonic-gate #include <signal.h> 410Sstevel@tonic-gate #include <lber.h> 420Sstevel@tonic-gate #include <ldap.h> 430Sstevel@tonic-gate #include <pwd.h> 440Sstevel@tonic-gate #include "ns_sldap.h" 450Sstevel@tonic-gate 460Sstevel@tonic-gate #define _ALIASES "aliases" 470Sstevel@tonic-gate #define _AUTOMOUNT "automount" 480Sstevel@tonic-gate #define _AUTHATTR "auth_attr" 490Sstevel@tonic-gate #define _AUUSER "audit_user" 500Sstevel@tonic-gate #define _BOOTPARAMS "bootparams" 510Sstevel@tonic-gate #define _DEFAULT "default" 520Sstevel@tonic-gate #define _ETHERS "ethers" 530Sstevel@tonic-gate #define _EXECATTR "exec_attr" 540Sstevel@tonic-gate #define _GROUP "group" 550Sstevel@tonic-gate #define _PROJECT "project" 560Sstevel@tonic-gate #define _HOSTS "hosts" 570Sstevel@tonic-gate #define _HOSTS6 "hosts" 580Sstevel@tonic-gate #define _NETGROUP "netgroup" 590Sstevel@tonic-gate #define _NETMASKS "netmasks" 600Sstevel@tonic-gate #define _NETWORKS "networks" 610Sstevel@tonic-gate #define _PASSWD "passwd" 620Sstevel@tonic-gate #define _PRINTERS "printers" 630Sstevel@tonic-gate #define _PROFATTR "prof_attr" 640Sstevel@tonic-gate #define _PROTOCOLS "protocols" 650Sstevel@tonic-gate #define _PUBLICKEY "publickey" 660Sstevel@tonic-gate #define _RPC "rpc" 670Sstevel@tonic-gate #define _SERVICES "services" 680Sstevel@tonic-gate #define _SHADOW "shadow" 690Sstevel@tonic-gate #define _USERATTR "user_attr" 70*1676Sjpk #define _TNRHDB "tnrhdb" 71*1676Sjpk #define _TNRHTP "tnrhtp" 720Sstevel@tonic-gate 730Sstevel@tonic-gate #define NSS_STR_PARSE_NO_ADDR (NSS_STR_PARSE_ERANGE + 100) 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define DOTTEDSUBDOMAIN(string) \ 760Sstevel@tonic-gate ((string != NULL) && (strchr(string, '.') != NULL)) 770Sstevel@tonic-gate #define SEARCHFILTERLEN 256 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 800Sstevel@tonic-gate * Superset the nss_backend_t abstract data type. This ADT has 810Sstevel@tonic-gate * been extended to include ldap associated data structures. 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate typedef struct ldap_backend *ldap_backend_ptr; 850Sstevel@tonic-gate typedef nss_status_t (*ldap_backend_op_t)(ldap_backend_ptr, void *); 860Sstevel@tonic-gate typedef int (*fnf)(ldap_backend_ptr be, nss_XbyY_args_t *argp); 870Sstevel@tonic-gate 880Sstevel@tonic-gate struct ldap_backend { 890Sstevel@tonic-gate ldap_backend_op_t *ops; 900Sstevel@tonic-gate nss_dbop_t nops; 910Sstevel@tonic-gate char *tablename; 920Sstevel@tonic-gate void *enumcookie; 930Sstevel@tonic-gate char *filter; 940Sstevel@tonic-gate int setcalled; 950Sstevel@tonic-gate const char **attrs; 960Sstevel@tonic-gate ns_ldap_result_t *result; 970Sstevel@tonic-gate fnf ldapobj2ent; 980Sstevel@tonic-gate void *netgroup_cookie; 990Sstevel@tonic-gate void *services_cookie; 1000Sstevel@tonic-gate char *toglue; 1010Sstevel@tonic-gate }; 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate extern nss_status_t _nss_ldap_destr(ldap_backend_ptr be, void *a); 1040Sstevel@tonic-gate extern nss_status_t _nss_ldap_endent(ldap_backend_ptr be, void *a); 1050Sstevel@tonic-gate extern nss_status_t _nss_ldap_setent(ldap_backend_ptr be, void *a); 1060Sstevel@tonic-gate extern nss_status_t _nss_ldap_getent(ldap_backend_ptr be, void *a); 1070Sstevel@tonic-gate nss_backend_t *_nss_ldap_constr(ldap_backend_op_t ops[], int nops, 1080Sstevel@tonic-gate char *tablename, const char **attrs, fnf ldapobj2ent); 1090Sstevel@tonic-gate extern nss_status_t _nss_ldap_nocb_lookup(ldap_backend_ptr be, 1100Sstevel@tonic-gate nss_XbyY_args_t *argp, char *database, 1110Sstevel@tonic-gate char *searchfilter, char *domain, 1120Sstevel@tonic-gate int (*init_filter_cb)( 1130Sstevel@tonic-gate const ns_ldap_search_desc_t *desc, 1140Sstevel@tonic-gate char **realfilter, const void *userdata), 1150Sstevel@tonic-gate const void *userdata); 1160Sstevel@tonic-gate extern nss_status_t _nss_ldap_lookup(ldap_backend_ptr be, 1170Sstevel@tonic-gate nss_XbyY_args_t *argp, char *database, 1180Sstevel@tonic-gate char *searchfilter, char *domain, 1190Sstevel@tonic-gate int (*init_filter_cb)( 1200Sstevel@tonic-gate const ns_ldap_search_desc_t *desc, 1210Sstevel@tonic-gate char **realfilter, const void *userdata), 1220Sstevel@tonic-gate const void *userdata); 1230Sstevel@tonic-gate extern void _clean_ldap_backend(ldap_backend_ptr be); 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate extern ns_ldap_attr_t *getattr(ns_ldap_result_t *result, int i); 1260Sstevel@tonic-gate extern const char *_strip_quotes(char *ipaddress); 1270Sstevel@tonic-gate extern int __nss2herrno(nss_status_t nsstat); 1280Sstevel@tonic-gate extern int propersubdomain(char *domain, char *subdomain); 1290Sstevel@tonic-gate extern int chophostdomain(char *string, char *host, char *domain); 1300Sstevel@tonic-gate extern char *_get_domain_name(char *cdn); 1310Sstevel@tonic-gate extern int _merge_SSD_filter(const ns_ldap_search_desc_t *desc, 1320Sstevel@tonic-gate char **realfilter, const void *userdata); 1330Sstevel@tonic-gate extern int _ldap_filter_name(char *filter_name, const char *name, 1340Sstevel@tonic-gate int filter_name_size); 1350Sstevel@tonic-gate extern nss_status_t switch_err(int rc, ns_ldap_error_t *error); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate extern void _nss_services_cookie_free(void **cookieP); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate #ifdef DEBUG 1400Sstevel@tonic-gate extern int printresult(ns_ldap_result_t *result); 1410Sstevel@tonic-gate #endif /* DEBUG */ 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate #ifdef __cplusplus 1440Sstevel@tonic-gate } 1450Sstevel@tonic-gate #endif 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate #endif /* _LDAP_COMMON_H */ 148