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 51687Sjanga * Common Development and Distribution License (the "License"). 61687Sjanga * 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 */ 21*12823SJulian.Pullen@Sun.COM 220Sstevel@tonic-gate /* 2312758SJulian.Pullen@Sun.COM * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _NS_INTERNAL_H 280Sstevel@tonic-gate #define _NS_INTERNAL_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <stdio.h> 350Sstevel@tonic-gate #include <sys/types.h> 360Sstevel@tonic-gate #include <sys/time.h> 370Sstevel@tonic-gate #include <thread.h> 380Sstevel@tonic-gate #include <lber.h> 390Sstevel@tonic-gate #include <ldap.h> 400Sstevel@tonic-gate #include "ns_sldap.h" 416842Sth160488 #include "ns_cache_door.h" 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * INTERNALLY USED CONSTANTS 450Sstevel@tonic-gate */ 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define MAXERROR 2000 480Sstevel@tonic-gate #define TRUE 1 490Sstevel@tonic-gate #define FALSE 0 500Sstevel@tonic-gate #define NSLDAPDIRECTORY "/var/ldap" 510Sstevel@tonic-gate #define NSCONFIGFILE "/var/ldap/ldap_client_file" 520Sstevel@tonic-gate #define NSCONFIGREFRESH "/var/ldap/ldap_client_file.refresh" 530Sstevel@tonic-gate #define NSCREDFILE "/var/ldap/ldap_client_cred" 540Sstevel@tonic-gate #define NSCREDREFRESH "/var/ldap/ldap_client_cred.refresh" 550Sstevel@tonic-gate #define ROTORSIZE 256 560Sstevel@tonic-gate #define MASK 0377 570Sstevel@tonic-gate #define LDAPMAXHARDLOOKUPTIME 256 580Sstevel@tonic-gate #define DONOTEDIT \ 590Sstevel@tonic-gate "Do not edit this file manually; your changes will be lost." \ 600Sstevel@tonic-gate "Please use ldapclient (1M) instead." 610Sstevel@tonic-gate #define MAXPORTNUMBER 65535 620Sstevel@tonic-gate #define MAXPORTNUMBER_STR "65535" 630Sstevel@tonic-gate #define CREDFILE 0 640Sstevel@tonic-gate #define CONFIGFILE 1 650Sstevel@tonic-gate #define UIDNUMFILTER "(&(objectclass=posixAccount)(uidnumber=%s))" 660Sstevel@tonic-gate #define UIDNUMFILTER_SSD "(&(%%s)(uidnumber=%s))" 670Sstevel@tonic-gate #define UIDFILTER "(&(objectclass=posixAccount)(uid=%s))" 680Sstevel@tonic-gate #define UIDFILTER_SSD "(&(%%s)(uid=%s))" 690Sstevel@tonic-gate #define HOSTFILTER "(&(objectclass=ipHost)(cn=%s))" 700Sstevel@tonic-gate #define HOSTFILTER_SSD "(&(%%s)(cn=%s))" 710Sstevel@tonic-gate 720Sstevel@tonic-gate #define SIMPLEPAGECTRLFLAG 1 730Sstevel@tonic-gate #define VLVCTRLFLAG 2 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define LISTPAGESIZE 1000 760Sstevel@tonic-gate #define ENUMPAGESIZE 100 770Sstevel@tonic-gate 780Sstevel@tonic-gate #define DEFMAX 8 790Sstevel@tonic-gate #define TOKENSEPARATOR '=' 800Sstevel@tonic-gate #define QUOTETOK '"' 810Sstevel@tonic-gate #define SPACETOK ' ' 820Sstevel@tonic-gate #define COMMATOK ',' 830Sstevel@tonic-gate #define COLONTOK ':' 840Sstevel@tonic-gate #define QUESTTOK '?' 850Sstevel@tonic-gate #define SEMITOK ';' 860Sstevel@tonic-gate #define TABTOK '\t' 870Sstevel@tonic-gate #define OPARATOK '(' 880Sstevel@tonic-gate #define CPARATOK ')' 890Sstevel@tonic-gate #define BSLTOK '\\' 900Sstevel@tonic-gate #define DOORLINESEP "\07" 916842Sth160488 #define DOORLINESEP_CHR 0x7 920Sstevel@tonic-gate #define COMMASEP ", " 930Sstevel@tonic-gate #define SPACESEP " " 940Sstevel@tonic-gate #define SEMISEP ";" 950Sstevel@tonic-gate #define COLONSEP ":" 960Sstevel@tonic-gate #define COLSPSEP ": " 970Sstevel@tonic-gate #define EQUALSEP "=" 980Sstevel@tonic-gate #define EQUSPSEP "= " 990Sstevel@tonic-gate #define LAST_VALUE (int)NS_LDAP_HOST_CERTPATH_P 10010132SMilan.Jurik@Sun.COM #define BUFSIZE BUFSIZ 1010Sstevel@tonic-gate #define DEFAULTCONFIGNAME "__default_config" 1020Sstevel@tonic-gate #define EXP_DEFAULT_TTL "43200" /* 12 hours TTL */ 1030Sstevel@tonic-gate #define CRYPTMARK "{NS1}" 1040Sstevel@tonic-gate #define DOORBUFFERSIZE 8192 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate #define LDIF_FMT_STR "%s: %s" 1070Sstevel@tonic-gate #define FILE_FMT_STR "%s= %s" 1080Sstevel@tonic-gate #define DOOR_FMT_STR "%s=%s" 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate #define SESSION_CACHE_INC 8 1110Sstevel@tonic-gate #define CONID_OFFSET 1024 1120Sstevel@tonic-gate #define NS_DEFAULT_BIND_TIMEOUT 30 /* timeout value in seconds */ 1130Sstevel@tonic-gate #define NS_DEFAULT_SEARCH_TIMEOUT 30 /* timeout value in seconds */ 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* max rdn length in conversion routines used by __ns_ldap_addTypedEntry() */ 1169288SSreedhar.Chalamalasetti@Sun.COM #define RDNSIZE 512 1170Sstevel@tonic-gate 1188821SMichen.Chang@Sun.COM /* 1198821SMichen.Chang@Sun.COM * special service used by ldap_cachemgr to indicate a shadow update 1208821SMichen.Chang@Sun.COM * is to be done with the credential of the administrator identity 1218821SMichen.Chang@Sun.COM */ 1228821SMichen.Chang@Sun.COM #define NS_ADMIN_SHADOW_UPDATE "shadow__admin_update" 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* Phase 1 profile information */ 1250Sstevel@tonic-gate #define _PROFILE1_OBJECTCLASS "SolarisNamingProfile" 1260Sstevel@tonic-gate #define _PROFILE_CONTAINER "profile" 1270Sstevel@tonic-gate #define _PROFILE_FILTER "(&(|(objectclass=%s)(objectclass=%s))(cn=%s))" 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* Phase 2 profile information */ 1300Sstevel@tonic-gate #define _PROFILE2_OBJECTCLASS "DUAConfigProfile" 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate /* Common to all profiles */ 1330Sstevel@tonic-gate #define _P_CN "cn" 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* Native LDAP Phase 1 Specific Profile Attributes */ 1360Sstevel@tonic-gate #define _P1_SERVERS "SolarisLDAPServers" 1370Sstevel@tonic-gate #define _P1_SEARCHBASEDN "SolarisSearchBaseDN" 1380Sstevel@tonic-gate #define _P1_CACHETTL "SolarisCacheTTL" 1390Sstevel@tonic-gate #define _P1_BINDDN "SolarisBindDN" 1400Sstevel@tonic-gate #define _P1_BINDPASSWORD "SolarisBindPassword" 1410Sstevel@tonic-gate #define _P1_AUTHMETHOD "SolarisAuthMethod" 1420Sstevel@tonic-gate #define _P1_TRANSPORTSECURITY "SolarisTransportSecurity" 1430Sstevel@tonic-gate #define _P1_CERTIFICATEPATH "SolarisCertificatePath" 1440Sstevel@tonic-gate #define _P1_CERTIFICATEPASSWORD "SolarisCertificatePassword" 1450Sstevel@tonic-gate #define _P1_DATASEARCHDN "SolarisDataSearchDN" 1460Sstevel@tonic-gate #define _P1_SEARCHSCOPE "SolarisSearchScope" 1470Sstevel@tonic-gate #define _P1_SEARCHTIMELIMIT "SolarisSearchTimeLimit" 1480Sstevel@tonic-gate #define _P1_PREFERREDSERVER "SolarisPreferredServer" 1490Sstevel@tonic-gate #define _P1_PREFERREDSERVERONLY "SolarisPreferredServerOnly" 1500Sstevel@tonic-gate #define _P1_SEARCHREFERRAL "SolarisSearchReferral" 1510Sstevel@tonic-gate #define _P1_BINDTIMELIMIT "SolarisBindTimeLimit" 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate /* Native LDAP Phase 2 Specific Profile Attributes */ 1540Sstevel@tonic-gate #define _P2_PREFERREDSERVER "preferredServerList" 1550Sstevel@tonic-gate #define _P2_DEFAULTSERVER "defaultServerList" 1560Sstevel@tonic-gate #define _P2_SEARCHBASEDN "defaultSearchBase" 1570Sstevel@tonic-gate #define _P2_SEARCHSCOPE "defaultSearchScope" 1580Sstevel@tonic-gate #define _P2_AUTHMETHOD "authenticationMethod" 1590Sstevel@tonic-gate #define _P2_CREDENTIALLEVEL "credentialLevel" 1600Sstevel@tonic-gate #define _P2_SERVICESEARCHDESC "serviceSearchDescriptor" 1610Sstevel@tonic-gate #define _P2_SEARCHTIMELIMIT "searchTimeLimit" 1620Sstevel@tonic-gate #define _P2_BINDTIMELIMIT "bindTimeLimit" 1630Sstevel@tonic-gate #define _P2_FOLLOWREFERRALS "followReferrals" 1640Sstevel@tonic-gate #define _P2_PROFILETTL "profileTTL" 1650Sstevel@tonic-gate #define _P2_ATTRIBUTEMAP "attributeMap" 1660Sstevel@tonic-gate #define _P2_OBJECTCLASSMAP "objectClassMap" 1670Sstevel@tonic-gate #define _P2_SERVICECREDLEVEL "serviceCredentialLevel" 1680Sstevel@tonic-gate #define _P2_SERVICEAUTHMETHOD "serviceAuthenticationMethod" 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* Control & SASL information from RootDSE door call */ 1710Sstevel@tonic-gate #define _SASLMECHANISM "supportedSASLmechanisms" 1720Sstevel@tonic-gate #define _SASLMECHANISM_LEN 23 1730Sstevel@tonic-gate #define _SUPPORTEDCONTROL "supportedControl" 1740Sstevel@tonic-gate #define _SUPPORTEDCONTROL_LEN 16 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate #define NS_HASH_MAX 257 1770Sstevel@tonic-gate #define NS_HASH_SCHEMA_MAPPING_EXISTED "=MAPPING EXISTED=" 1780Sstevel@tonic-gate #define NS_HASH_RC_SUCCESS 1 1790Sstevel@tonic-gate #define NS_HASH_RC_NO_MEMORY -1 1800Sstevel@tonic-gate #define NS_HASH_RC_CONFIG_ERROR -2 1810Sstevel@tonic-gate #define NS_HASH_RC_EXISTED -3 1820Sstevel@tonic-gate #define NS_HASH_RC_SYNTAX_ERROR -4 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate /* Password management related error message from iDS ldap server */ 1850Sstevel@tonic-gate #define NS_PWDERR_MAXTRIES \ 1860Sstevel@tonic-gate "Exceed password retry limit." 1870Sstevel@tonic-gate #define NS_PWDERR_EXPIRED \ 1880Sstevel@tonic-gate "password expired!" 1890Sstevel@tonic-gate #define NS_PWDERR_ACCT_INACTIVATED \ 1900Sstevel@tonic-gate "Account inactivated. Contact system administrator." 1910Sstevel@tonic-gate #define NS_PWDERR_CHANGE_NOT_ALLOW \ 1920Sstevel@tonic-gate "user is not allowed to change password" 1930Sstevel@tonic-gate #define NS_PWDERR_INVALID_SYNTAX \ 1940Sstevel@tonic-gate "invalid password syntax" 1950Sstevel@tonic-gate #define NS_PWDERR_TRIVIAL_PASSWD \ 1960Sstevel@tonic-gate "Password failed triviality check" 1970Sstevel@tonic-gate #define NS_PWDERR_IN_HISTORY \ 1980Sstevel@tonic-gate "password in history" 1990Sstevel@tonic-gate #define NS_PWDERR_WITHIN_MIN_AGE \ 2000Sstevel@tonic-gate "within password minimum age" 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * INTERNALLY USED MACROS 2040Sstevel@tonic-gate */ 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate void __s_api_debug_pause(int priority, int st, const char *mesg); 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate #define NULL_OR_STR(str) (!(str) || *(str) == '\0' ? "<NULL>" : (str)) 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate /* 2110Sstevel@tonic-gate * MKERROR: builds the error structure and fills in the status and 2120Sstevel@tonic-gate * the message. The message must be a freeable (non-static) string. 2130Sstevel@tonic-gate * If it fails to allocate memory for the error structure, 2140Sstevel@tonic-gate * it will return the retErr. 2150Sstevel@tonic-gate */ 2160Sstevel@tonic-gate #define MKERROR(priority, err, st, mesg, retErr) \ 2170Sstevel@tonic-gate if (((err) = calloc(1, sizeof (struct ns_ldap_error))) == NULL) \ 2180Sstevel@tonic-gate return (retErr); \ 2190Sstevel@tonic-gate (err)->message = mesg; \ 2200Sstevel@tonic-gate (err)->status = (st); \ 2210Sstevel@tonic-gate __s_api_debug_pause(priority, st, (err)->message); 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate /* 2240Sstevel@tonic-gate * MKERROR_PWD_MGMT is almost the same as MKERROR 2250Sstevel@tonic-gate * except that it takes two more inputs to fill in the 2260Sstevel@tonic-gate * password management information part of the 2270Sstevel@tonic-gate * ns_ldap_error structure pointed to by err, 2280Sstevel@tonic-gate * and it does not log a syslog message. 2290Sstevel@tonic-gate */ 2300Sstevel@tonic-gate #define MKERROR_PWD_MGMT(err, st, mesg, pwd_status, sec_until_exp, retErr) \ 2310Sstevel@tonic-gate if (((err) = calloc(1, sizeof (struct ns_ldap_error))) == NULL) \ 2320Sstevel@tonic-gate return (retErr); \ 2330Sstevel@tonic-gate (err)->message = mesg; \ 2340Sstevel@tonic-gate (err)->status = (st); \ 2350Sstevel@tonic-gate (err)->pwd_mgmt.status = (pwd_status); \ 2360Sstevel@tonic-gate (err)->pwd_mgmt.sec_until_expired = (sec_until_exp); 2370Sstevel@tonic-gate 2380Sstevel@tonic-gate #ifdef DEBUG 2390Sstevel@tonic-gate #define NSLDAPTRACE(variable, setequal, message) \ 2400Sstevel@tonic-gate if (variable > 0 || ((setequal != 0) && (variable == setequal))) { \ 2410Sstevel@tonic-gate char buf[BUFSIZ]; \ 2420Sstevel@tonic-gate (void) snprintf(buf, BUFSIZ, message); \ 2430Sstevel@tonic-gate (void) write(__ldap_debug_file, buf); \ 2440Sstevel@tonic-gate } 2450Sstevel@tonic-gate #endif 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate /* 2480Sstevel@tonic-gate * INTERNAL DATA STRUCTURES 2490Sstevel@tonic-gate */ 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* 2520Sstevel@tonic-gate * configuration entry type 2530Sstevel@tonic-gate */ 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate typedef enum { 2560Sstevel@tonic-gate SERVERCONFIG = 1, 2570Sstevel@tonic-gate CLIENTCONFIG = 2, 2580Sstevel@tonic-gate CREDCONFIG = 3 2590Sstevel@tonic-gate } ns_conftype_t; 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate /* 2620Sstevel@tonic-gate * datatype of a config entry 2630Sstevel@tonic-gate */ 2640Sstevel@tonic-gate 2650Sstevel@tonic-gate typedef enum { 2660Sstevel@tonic-gate NS_UNKNOWN = 0, 2670Sstevel@tonic-gate CHARPTR = 1, /* Single character pointer */ 2680Sstevel@tonic-gate ARRAYCP = 2, /* comma sep array of char pointers */ 2690Sstevel@tonic-gate ARRAYAUTH = 3, /* Array of auths */ 2700Sstevel@tonic-gate TIMET = 4, /* time relative value (TTL) */ 2710Sstevel@tonic-gate INT = 5, /* single integer */ 2720Sstevel@tonic-gate SSDLIST = 6, /* service search descriptor */ 2730Sstevel@tonic-gate ATTRMAP = 7, /* attribute mapping */ 2740Sstevel@tonic-gate OBJMAP = 8, /* objectclass mapping */ 2750Sstevel@tonic-gate SERVLIST = 9, /* serverlist (SP sep array) */ 2760Sstevel@tonic-gate ARRAYCRED = 10, /* Array of credentialLevels */ 2770Sstevel@tonic-gate SAMLIST = 11, /* serviceAuthenticationMethod */ 2780Sstevel@tonic-gate SCLLIST = 12 /* serviceCredentialLevel */ 2790Sstevel@tonic-gate } ns_datatype_t; 2800Sstevel@tonic-gate 2810Sstevel@tonic-gate typedef enum { 2820Sstevel@tonic-gate NS_SUCCESS, 2830Sstevel@tonic-gate NS_NOTFOUND, 2840Sstevel@tonic-gate NS_PARSE_ERR 2850Sstevel@tonic-gate } ns_parse_status; 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate typedef enum { 2880Sstevel@tonic-gate NS_DOOR_FMT = 1, 2890Sstevel@tonic-gate NS_LDIF_FMT = 2, 2900Sstevel@tonic-gate NS_FILE_FMT = 3 2910Sstevel@tonic-gate } ns_strfmt_t; 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate /* 2940Sstevel@tonic-gate * This enum reduces the number of version string compares 2950Sstevel@tonic-gate * against NS_LDAP_VERSION_1 and NS_LDAP_VERSION_2 2960Sstevel@tonic-gate */ 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate typedef enum { 2990Sstevel@tonic-gate NS_LDAP_V1 = 1000, 3000Sstevel@tonic-gate NS_LDAP_V2 = 2000 3010Sstevel@tonic-gate } ns_version_t; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * enum<->string mapping construct 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate typedef struct ns_enum_map { 3080Sstevel@tonic-gate int value; 3090Sstevel@tonic-gate char *name; 3100Sstevel@tonic-gate } ns_enum_map; 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate #define ENUM2INT(x) ((int)(x)) 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate #define INT2PARAMINDEXENUM(x) ((ParamIndexType)(x)) 3150Sstevel@tonic-gate #define INT2SEARCHREFENUM(x) ((SearchRef_t)(x)) 3160Sstevel@tonic-gate #define INT2SCOPEENUM(x) ((ScopeType_t)(x)) 3170Sstevel@tonic-gate #define INT2AUTHENUM(x) ((AuthType_t)(x)) 3180Sstevel@tonic-gate #define INT2SECENUM(x) ((TlsType_t)(x)) 3190Sstevel@tonic-gate #define INT2PREFONLYENUM(x) ((PrefOnly_t)(x)) 3200Sstevel@tonic-gate #define INT2CREDLEVELENUM(x) ((CredLevel_t)(x)) 3218821SMichen.Chang@Sun.COM #define INT2SHADOWUPDATENUM(x) ((enableShadowUpdate_t)(x)) 3220Sstevel@tonic-gate 3230Sstevel@tonic-gate #define INT2LDAPRETURN(x) ((ns_ldap_return_code)(x)) 3240Sstevel@tonic-gate #define INT2CONFIGRETURN(x) ((ns_ldap_config_return_code)(x)) 3250Sstevel@tonic-gate #define INT2PARTIALRETURN(x) ((ns_ldap_partial_return_code)(x)) 3260Sstevel@tonic-gate 3270Sstevel@tonic-gate /* 3280Sstevel@tonic-gate * This structure maps service name to rdn components 3290Sstevel@tonic-gate * for use in __ns_getDNs. It also defines the SSD-to-use 3300Sstevel@tonic-gate * service for use in __s_api_get_SSDtoUse_service. 3310Sstevel@tonic-gate * The idea of an SSD-to-use service is to reduce the configuration 3320Sstevel@tonic-gate * complexity. For a service, which does not have its own entries in 3330Sstevel@tonic-gate * the LDAP directory, SSD for it is useless, and should not be set. 3340Sstevel@tonic-gate * But since this service must share the container with at least 3350Sstevel@tonic-gate * one other service which does have it own entries, the SSD for 3360Sstevel@tonic-gate * this other service will be shared by this service. 3370Sstevel@tonic-gate * This other service is called the SSD-to-use service. 3380Sstevel@tonic-gate * 3390Sstevel@tonic-gate */ 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate typedef struct ns_service_map { 3420Sstevel@tonic-gate char *service; 3430Sstevel@tonic-gate char *rdn; 3440Sstevel@tonic-gate char *SSDtoUse_service; 3450Sstevel@tonic-gate } ns_service_map; 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate /* 3480Sstevel@tonic-gate * This structure contains a single mapping from: 3490Sstevel@tonic-gate * service:orig -> list of mapped 3500Sstevel@tonic-gate */ 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate typedef enum { 3530Sstevel@tonic-gate NS_ATTR_MAP, 3540Sstevel@tonic-gate NS_OBJ_MAP 3550Sstevel@tonic-gate } ns_maptype_t; 3560Sstevel@tonic-gate 3570Sstevel@tonic-gate typedef struct ns_mapping { 3580Sstevel@tonic-gate ns_maptype_t type; 3590Sstevel@tonic-gate char *service; 3600Sstevel@tonic-gate char *orig; 3610Sstevel@tonic-gate char **map; 3620Sstevel@tonic-gate } ns_mapping_t; 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate /* 3650Sstevel@tonic-gate * The following is the list of internal libsldap configuration data 3660Sstevel@tonic-gate * structures. The configuration is populated normally once per 3670Sstevel@tonic-gate * application. The assumption is that in applications can be 3680Sstevel@tonic-gate * relatively short lived (IE ls via nsswitch) so it is important to 3690Sstevel@tonic-gate * keep configuration to a minimum, but keep lookups fast. 3700Sstevel@tonic-gate * 3710Sstevel@tonic-gate * Assumptions: 3720Sstevel@tonic-gate * 1 configuration entry per domain, and almost always 1 domain 3730Sstevel@tonic-gate * per app. Hooks exist for multiple domains per app. 3740Sstevel@tonic-gate * 3750Sstevel@tonic-gate * Configurations are read in from client file cache or from LDAP. 3760Sstevel@tonic-gate * Attribute/objectclass mappings are hashed to improve lookup 3770Sstevel@tonic-gate * speed. 3780Sstevel@tonic-gate */ 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate /* 3810Sstevel@tonic-gate * Hash entry types 3820Sstevel@tonic-gate */ 3830Sstevel@tonic-gate typedef enum _ns_hashtype_t { 3840Sstevel@tonic-gate NS_HASH_AMAP = 1, /* attr map */ 3850Sstevel@tonic-gate NS_HASH_RAMAP = 2, /* reverse attr map */ 3860Sstevel@tonic-gate NS_HASH_OMAP = 3, /* oc map */ 3870Sstevel@tonic-gate NS_HASH_ROMAP = 4, /* reverse oc map */ 3880Sstevel@tonic-gate NS_HASH_VOID = 5 3890Sstevel@tonic-gate } ns_hashtype_t; 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate typedef struct ns_hash { 3920Sstevel@tonic-gate ns_hashtype_t h_type; 3930Sstevel@tonic-gate ns_mapping_t *h_map; 3940Sstevel@tonic-gate struct ns_hash *h_next; 3950Sstevel@tonic-gate struct ns_hash *h_llnext; 3960Sstevel@tonic-gate } ns_hash_t; 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate /* 3990Sstevel@tonic-gate * This structure defines the format of an internal configuration 4000Sstevel@tonic-gate * parameter for ns_ldap client. 4010Sstevel@tonic-gate */ 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate typedef struct ns_param { 4040Sstevel@tonic-gate ns_datatype_t ns_ptype; 4050Sstevel@tonic-gate int ns_acnt; 4060Sstevel@tonic-gate union { 4070Sstevel@tonic-gate char **ppc; 4080Sstevel@tonic-gate int *pi; 4090Sstevel@tonic-gate char *pc; 4100Sstevel@tonic-gate int i; 4110Sstevel@tonic-gate time_t tm; 4120Sstevel@tonic-gate } ns_pu; 4130Sstevel@tonic-gate } ns_param_t; 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate #define ns_ppc ns_pu.ppc 4160Sstevel@tonic-gate #define ns_pi ns_pu.pi 4170Sstevel@tonic-gate #define ns_pc ns_pu.pc 4180Sstevel@tonic-gate #define ns_i ns_pu.i 4190Sstevel@tonic-gate #define ns_tm ns_pu.tm 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate /* 4220Sstevel@tonic-gate * This structure defines an instance of a configuration structure. 4230Sstevel@tonic-gate * paramList contains the current ns_ldap parameter configuration 4240Sstevel@tonic-gate * and hashTbl contain the current attribute/objectclass mappings. 4250Sstevel@tonic-gate * Parameters are indexed by using the value assigned to the parameter 4260Sstevel@tonic-gate * in ParamIndexType. 4270Sstevel@tonic-gate */ 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate typedef struct ns_config { 4300Sstevel@tonic-gate char *domainName; 4310Sstevel@tonic-gate ns_version_t version; 4320Sstevel@tonic-gate ns_param_t paramList[NS_LDAP_MAX_PIT_P]; 4330Sstevel@tonic-gate ns_hash_t *hashTbl[NS_HASH_MAX]; 4340Sstevel@tonic-gate ns_hash_t *llHead; 4350Sstevel@tonic-gate ns_ldap_entry_t *RootDSE; 4360Sstevel@tonic-gate boolean_t delete; 4370Sstevel@tonic-gate mutex_t config_mutex; 4380Sstevel@tonic-gate int nUse; 4396842Sth160488 ldap_get_chg_cookie_t config_cookie; 4400Sstevel@tonic-gate } ns_config_t; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate /* 4430Sstevel@tonic-gate * This structure defines the mapping of the NSCONFIGFILE file 4440Sstevel@tonic-gate * statements into their corresponding SolarisNamingProfile, 4450Sstevel@tonic-gate * Posix Mapping LDAP attributes, and to their corresponding 4460Sstevel@tonic-gate * ParamIndexType enum mapping. THe ParamIndexType enum 4470Sstevel@tonic-gate * definitions can be found in ns_ldap.h. This structure also 4480Sstevel@tonic-gate * defines the default values that are used when a value either 4490Sstevel@tonic-gate * does not exist or is undefined. 4500Sstevel@tonic-gate */ 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate typedef struct ns_default_config { 4530Sstevel@tonic-gate const char *name; /* config file parameter name */ 4540Sstevel@tonic-gate ParamIndexType index; /* config file enum index */ 4550Sstevel@tonic-gate ns_conftype_t config_type; /* CLIENT/SERVER/CREDCONFIG */ 4560Sstevel@tonic-gate ns_datatype_t data_type; /* ppc,pi,pc,int etc... */ 4570Sstevel@tonic-gate int single_valued; /* TRUE OR FALSE */ 4580Sstevel@tonic-gate ns_version_t version; /* Version # for attribute */ 4590Sstevel@tonic-gate const char *profile_name; /* profile schema attribute name */ 4600Sstevel@tonic-gate ns_param_t defval; /* config file parameter default */ 4610Sstevel@tonic-gate int (*ns_verify)(ParamIndexType i, 4620Sstevel@tonic-gate struct ns_default_config *def, 4630Sstevel@tonic-gate ns_param_t *param, 4640Sstevel@tonic-gate char *errbuf); 4650Sstevel@tonic-gate ns_enum_map *allowed; /* allowed values */ 4660Sstevel@tonic-gate } ns_default_config; 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate /* 4700Sstevel@tonic-gate * This typedef enumerates all the supported authentication 4710Sstevel@tonic-gate * mechanisms currently supported in this library 4720Sstevel@tonic-gate */ 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate typedef enum EnumAuthType { 4750Sstevel@tonic-gate NS_LDAP_EA_NONE = 0, 4760Sstevel@tonic-gate NS_LDAP_EA_SIMPLE = 1, 4770Sstevel@tonic-gate NS_LDAP_EA_SASL_NONE = 2, 4780Sstevel@tonic-gate NS_LDAP_EA_SASL_CRAM_MD5 = 3, 4790Sstevel@tonic-gate NS_LDAP_EA_SASL_DIGEST_MD5 = 4, 4800Sstevel@tonic-gate NS_LDAP_EA_SASL_DIGEST_MD5_INT = 5, 4810Sstevel@tonic-gate NS_LDAP_EA_SASL_DIGEST_MD5_CONF = 6, 4820Sstevel@tonic-gate NS_LDAP_EA_SASL_EXTERNAL = 7, 4832830Sdjl NS_LDAP_EA_SASL_GSSAPI = 8, 4840Sstevel@tonic-gate NS_LDAP_EA_SASL_SPNEGO = 9, /* unsupported */ 4850Sstevel@tonic-gate NS_LDAP_EA_TLS_NONE = 10, 4860Sstevel@tonic-gate NS_LDAP_EA_TLS_SIMPLE = 11, 4870Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_NONE = 12, 4880Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_CRAM_MD5 = 13, 4890Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_DIGEST_MD5 = 14, 4900Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_DIGEST_MD5_INT = 15, 4910Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_DIGEST_MD5_CONF = 16, 4920Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_EXTERNAL = 17, 4930Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_GSSAPI = 18, /* unsupported */ 4940Sstevel@tonic-gate NS_LDAP_EA_TLS_SASL_SPNEGO = 19 /* unsupported */ 4950Sstevel@tonic-gate } EnumAuthType_t; 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate 4980Sstevel@tonic-gate /* 4990Sstevel@tonic-gate * this enum lists the various states of the search state machine 5000Sstevel@tonic-gate */ 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate typedef enum { 5030Sstevel@tonic-gate INIT = 1, 5040Sstevel@tonic-gate EXIT = 2, 5050Sstevel@tonic-gate NEXT_SEARCH_DESCRIPTOR = 3, 5060Sstevel@tonic-gate GET_SESSION = 4, 5070Sstevel@tonic-gate NEXT_SESSION = 5, 5080Sstevel@tonic-gate RESTART_SESSION = 6, 5090Sstevel@tonic-gate NEXT_SEARCH = 7, 5100Sstevel@tonic-gate NEXT_VLV = 8, 5110Sstevel@tonic-gate NEXT_PAGE = 9, 5120Sstevel@tonic-gate ONE_SEARCH = 10, 5130Sstevel@tonic-gate DO_SEARCH = 11, 5140Sstevel@tonic-gate NEXT_RESULT = 12, 5150Sstevel@tonic-gate MULTI_RESULT = 13, 5160Sstevel@tonic-gate PROCESS_RESULT = 14, 5170Sstevel@tonic-gate END_PROCESS_RESULT = 15, 5180Sstevel@tonic-gate END_RESULT = 16, 5190Sstevel@tonic-gate NEXT_REFERRAL = 17, 5200Sstevel@tonic-gate GET_REFERRAL_SESSION = 18, 5210Sstevel@tonic-gate ERROR = 19, 5221179Svv149972 LDAP_ERROR = 20, 5234765Smj162486 GET_ACCT_MGMT_INFO = 21, 5246842Sth160488 CLEAR_RESULTS = 22, 5256842Sth160488 REINIT = 23 5260Sstevel@tonic-gate } ns_state_t; 5270Sstevel@tonic-gate 5280Sstevel@tonic-gate /* 5290Sstevel@tonic-gate * this enum lists the various states of the write state machine 5300Sstevel@tonic-gate */ 5310Sstevel@tonic-gate typedef enum { 5320Sstevel@tonic-gate W_INIT = 1, 5330Sstevel@tonic-gate W_EXIT = 2, 5340Sstevel@tonic-gate GET_CONNECTION = 3, 5350Sstevel@tonic-gate SELECT_OPERATION_SYNC = 4, 5360Sstevel@tonic-gate SELECT_OPERATION_ASYNC = 5, 5370Sstevel@tonic-gate DO_ADD_SYNC = 6, 5380Sstevel@tonic-gate DO_DELETE_SYNC = 7, 5390Sstevel@tonic-gate DO_MODIFY_SYNC = 8, 5400Sstevel@tonic-gate DO_ADD_ASYNC = 9, 5410Sstevel@tonic-gate DO_DELETE_ASYNC = 10, 5420Sstevel@tonic-gate DO_MODIFY_ASYNC = 11, 5430Sstevel@tonic-gate GET_RESULT_SYNC = 12, 5440Sstevel@tonic-gate GET_RESULT_ASYNC = 13, 5450Sstevel@tonic-gate PARSE_RESULT = 14, 5460Sstevel@tonic-gate GET_REFERRAL_CONNECTION = 15, 5470Sstevel@tonic-gate W_LDAP_ERROR = 16, 5480Sstevel@tonic-gate W_ERROR = 17 5490Sstevel@tonic-gate } ns_write_state_t; 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate typedef int ConnectionID; 5530Sstevel@tonic-gate 5540Sstevel@tonic-gate /* 55512758SJulian.Pullen@Sun.COM * Server side sort type. Orginally the server side sort 55612758SJulian.Pullen@Sun.COM * was set to "cn uid". This did not work with AD and 55712758SJulian.Pullen@Sun.COM * hence single sort attribute was odopted. We dont 55812758SJulian.Pullen@Sun.COM * know which server side sort will work with the 55912758SJulian.Pullen@Sun.COM * Directory and hence we discover which method works. 56012758SJulian.Pullen@Sun.COM */ 56112758SJulian.Pullen@Sun.COM typedef enum { 56212758SJulian.Pullen@Sun.COM SSS_UNKNOWN = 0, 56312758SJulian.Pullen@Sun.COM SSS_SINGLE_ATTR = 1, 56412758SJulian.Pullen@Sun.COM SSS_CN_UID_ATTRS = 2 56512758SJulian.Pullen@Sun.COM } ns_srvsidesort_t; 56612758SJulian.Pullen@Sun.COM 56712758SJulian.Pullen@Sun.COM /* 5680Sstevel@tonic-gate * This structure is used by ns_connect to create and manage 5690Sstevel@tonic-gate * one or more ldap connections within the library. 5700Sstevel@tonic-gate */ 5710Sstevel@tonic-gate typedef struct connection { 5720Sstevel@tonic-gate ConnectionID connectionId; 5732830Sdjl boolean_t usedBit; /* true if only used by */ 5742830Sdjl /* one thread and not shared */ 5752830Sdjl /* by other threads */ 5763387Schinlong pid_t pid; /* process id */ 5770Sstevel@tonic-gate char *serverAddr; 5782830Sdjl ns_cred_t *auth; 5790Sstevel@tonic-gate LDAP *ld; 5800Sstevel@tonic-gate thread_t threadID; /* thread ID using it */ 5810Sstevel@tonic-gate struct ns_ldap_cookie *cookieInfo; 5820Sstevel@tonic-gate char **controls; /* from server_info */ 5830Sstevel@tonic-gate char **saslMechanisms; /* from server_info */ 5840Sstevel@tonic-gate } Connection; 5850Sstevel@tonic-gate 5860Sstevel@tonic-gate #define ONE_STEP 1 5870Sstevel@tonic-gate 5880Sstevel@tonic-gate /* 5890Sstevel@tonic-gate * This structure is for referrals processing. 5900Sstevel@tonic-gate * The data are from referral URLs returned by 5910Sstevel@tonic-gate * LDAP servers 5920Sstevel@tonic-gate */ 5930Sstevel@tonic-gate typedef struct ns_referral_info { 5940Sstevel@tonic-gate struct ns_referral_info *next; 5950Sstevel@tonic-gate char *refHost; 5960Sstevel@tonic-gate int refScope; 5970Sstevel@tonic-gate char *refDN; 5980Sstevel@tonic-gate char *refFilter; 5990Sstevel@tonic-gate } ns_referral_info_t; 6000Sstevel@tonic-gate 6016616Sdm199847 struct ns_ldap_cookie; 6026616Sdm199847 6036616Sdm199847 /* 6046616Sdm199847 * Batch used by __ns_ldap_list_batch_xxx API 6056616Sdm199847 */ 6066616Sdm199847 struct ns_ldap_list_batch { 6076616Sdm199847 uint32_t nactive; 6086616Sdm199847 struct ns_ldap_cookie *next_cookie; 6096616Sdm199847 struct ns_ldap_cookie *cookie_list; 6106616Sdm199847 }; 6116616Sdm199847 6126842Sth160488 struct ns_conn_user; 6136842Sth160488 typedef struct ns_conn_user ns_conn_user_t; 6146842Sth160488 6150Sstevel@tonic-gate /* 6160Sstevel@tonic-gate * This structure used internally in searches 6170Sstevel@tonic-gate */ 6180Sstevel@tonic-gate 6190Sstevel@tonic-gate typedef struct ns_ldap_cookie { 6200Sstevel@tonic-gate /* INPUTS */ 6210Sstevel@tonic-gate /* server list position */ 6220Sstevel@tonic-gate 6230Sstevel@tonic-gate /* service search descriptor list & position */ 6240Sstevel@tonic-gate ns_ldap_search_desc_t **sdlist; 6250Sstevel@tonic-gate ns_ldap_search_desc_t **sdpos; 6260Sstevel@tonic-gate 6270Sstevel@tonic-gate /* search filter callback */ 6280Sstevel@tonic-gate int use_filtercb; 6290Sstevel@tonic-gate int (*init_filter_cb)(const ns_ldap_search_desc_t *desc, 6300Sstevel@tonic-gate char **realfilter, const void *userdata); 6310Sstevel@tonic-gate 6320Sstevel@tonic-gate /* user callback */ 6330Sstevel@tonic-gate int use_usercb; 6340Sstevel@tonic-gate int (*callback)(const ns_ldap_entry_t *entry, 6350Sstevel@tonic-gate const void *userdata); 6360Sstevel@tonic-gate const void *userdata; 6370Sstevel@tonic-gate 6380Sstevel@tonic-gate int followRef; 6390Sstevel@tonic-gate int use_paging; 6400Sstevel@tonic-gate char *service; 6410Sstevel@tonic-gate char *i_filter; 6420Sstevel@tonic-gate const char * const *i_attr; 64312758SJulian.Pullen@Sun.COM const char *i_sortattr; 6440Sstevel@tonic-gate const ns_cred_t *i_auth; 6450Sstevel@tonic-gate int i_flags; 6460Sstevel@tonic-gate 6470Sstevel@tonic-gate /* OUTPUTS */ 6480Sstevel@tonic-gate ns_ldap_result_t *result; 6490Sstevel@tonic-gate ns_ldap_entry_t *nextEntry; 6500Sstevel@tonic-gate /* Error data */ 6510Sstevel@tonic-gate int err_rc; 6520Sstevel@tonic-gate ns_ldap_error_t *errorp; 6530Sstevel@tonic-gate 6540Sstevel@tonic-gate /* PRIVATE */ 6550Sstevel@tonic-gate ns_state_t state; 6560Sstevel@tonic-gate ns_state_t new_state; 6570Sstevel@tonic-gate ns_state_t next_state; 6580Sstevel@tonic-gate 6590Sstevel@tonic-gate Connection *conn; 660493Ssdussud #define conn_auth_type conn->auth->auth.type 6610Sstevel@tonic-gate ConnectionID connectionId; 6620Sstevel@tonic-gate 6630Sstevel@tonic-gate /* paging VLV/SIMPLEPAGE data */ 6640Sstevel@tonic-gate int listType; 6650Sstevel@tonic-gate unsigned long index; 6660Sstevel@tonic-gate LDAPControl **p_serverctrls; 66712758SJulian.Pullen@Sun.COM ns_srvsidesort_t sortTypeTry; 66812758SJulian.Pullen@Sun.COM int entryCount; 6690Sstevel@tonic-gate 6700Sstevel@tonic-gate int scope; 6710Sstevel@tonic-gate char *basedn; 6720Sstevel@tonic-gate char *filter; 6730Sstevel@tonic-gate char **attribute; 6740Sstevel@tonic-gate 6750Sstevel@tonic-gate /* RESULT PROCESSING */ 6760Sstevel@tonic-gate int msgId; 6770Sstevel@tonic-gate LDAPMessage *resultMsg; 6780Sstevel@tonic-gate 6790Sstevel@tonic-gate char **dns; 6800Sstevel@tonic-gate char *currentdn; 6810Sstevel@tonic-gate int flag; 6820Sstevel@tonic-gate struct berval *ctrlCookie; 6830Sstevel@tonic-gate 6840Sstevel@tonic-gate /* REFERRALS PROCESSING */ 6850Sstevel@tonic-gate /* referralinfo list & position */ 6860Sstevel@tonic-gate ns_referral_info_t *reflist; 6870Sstevel@tonic-gate ns_referral_info_t *refpos; 6880Sstevel@tonic-gate /* search timeout value */ 6890Sstevel@tonic-gate struct timeval search_timeout; 6901179Svv149972 /* response control to hold account management information */ 6911179Svv149972 LDAPControl **resultctrl; 6921179Svv149972 /* Flag to indicate password less account management is required */ 6931179Svv149972 int nopasswd_acct_mgmt; 6943387Schinlong int err_from_result; 6956842Sth160488 ns_conn_user_t *conn_user; 6966616Sdm199847 6976616Sdm199847 /* BATCH PROCESSING */ 6986616Sdm199847 ns_ldap_list_batch_t *batch; 6996616Sdm199847 boolean_t no_wait; 7006842Sth160488 boolean_t reinit_on_retriable_err; 7016842Sth160488 int retries; 7026616Sdm199847 ns_ldap_result_t **caller_result; 7036616Sdm199847 ns_ldap_error_t **caller_errorp; 7046616Sdm199847 int *caller_rc; 7056616Sdm199847 struct ns_ldap_cookie *next_cookie_in_batch; 7060Sstevel@tonic-gate } ns_ldap_cookie_t; 7070Sstevel@tonic-gate 7080Sstevel@tonic-gate /* 7090Sstevel@tonic-gate * This structure is part of the return value information for 7100Sstevel@tonic-gate * __s_api_requestServer. The routine that requests a new server 7110Sstevel@tonic-gate * from the cache manager 7120Sstevel@tonic-gate */ 7130Sstevel@tonic-gate typedef struct ns_server_info { 7140Sstevel@tonic-gate char *server; 7154522Schinlong char *serverFQDN; 7160Sstevel@tonic-gate char **controls; 7170Sstevel@tonic-gate char **saslMechanisms; 7180Sstevel@tonic-gate } ns_server_info_t; 7190Sstevel@tonic-gate 7200Sstevel@tonic-gate /* 7212830Sdjl * sasl callback function parameters 7222830Sdjl */ 7232830Sdjl typedef struct ns_sasl_cb_param { 7242830Sdjl char *mech; 7252830Sdjl char *authid; 7262830Sdjl char *authzid; 7272830Sdjl char *passwd; 7282830Sdjl char *realm; 7292830Sdjl } ns_sasl_cb_param_t; 7302830Sdjl 7312830Sdjl /* Multiple threads per connection variable */ 7322830Sdjl extern int MTperConn; 7332830Sdjl 7342830Sdjl /* 7350Sstevel@tonic-gate * INTERNAL GLOBAL DEFINITIONS AND FUNCTION DECLARATIONS 7360Sstevel@tonic-gate */ 7370Sstevel@tonic-gate 7380Sstevel@tonic-gate #ifdef DEBUG 7390Sstevel@tonic-gate extern int __ldap_debug_file; 7400Sstevel@tonic-gate extern int __ldap_debug_api; 7410Sstevel@tonic-gate extern int __ldap_debug_ldap; 7420Sstevel@tonic-gate extern int __ldap_debug_servers; 7430Sstevel@tonic-gate #endif 7440Sstevel@tonic-gate 7450Sstevel@tonic-gate /* internal connection APIs */ 7460Sstevel@tonic-gate void DropConnection(ConnectionID, int); 7470Sstevel@tonic-gate int __s_api_getServers(char *** servers, ns_ldap_error_t ** error); 7480Sstevel@tonic-gate 7490Sstevel@tonic-gate int __s_get_enum_value(ns_config_t *ptr, char *value, ParamIndexType i); 7500Sstevel@tonic-gate char *__s_get_auth_name(ns_config_t *ptr, AuthType_t type); 7510Sstevel@tonic-gate char *__s_get_security_name(ns_config_t *ptr, TlsType_t type); 7520Sstevel@tonic-gate char *__s_get_scope_name(ns_config_t *ptr, ScopeType_t type); 7530Sstevel@tonic-gate char *__s_get_pref_name(PrefOnly_t type); 7540Sstevel@tonic-gate char *__s_get_searchref_name(ns_config_t *ptr, SearchRef_t type); 7558821SMichen.Chang@Sun.COM char *__s_get_shadowupdate_name(enableShadowUpdate_t type); 7560Sstevel@tonic-gate char *__s_get_hostcertpath(void); 7576842Sth160488 void __s_api_free_sessionPool(); 7586842Sth160488 int __s_api_requestServer(const char *request, const char *server, 7596842Sth160488 ns_server_info_t *ret, ns_ldap_error_t **error, const char *addrType); 7600Sstevel@tonic-gate 7610Sstevel@tonic-gate 7620Sstevel@tonic-gate /* ************ internal sldap-api functions *********** */ 7630Sstevel@tonic-gate void __ns_ldap_freeEntry(ns_ldap_entry_t *ep); 7640Sstevel@tonic-gate void __s_api_split_key_value(char *buffer, char **name, char **value); 7650Sstevel@tonic-gate int __s_api_printResult(ns_ldap_result_t *); 7660Sstevel@tonic-gate int __s_api_getSearchScope(int *, ns_ldap_error_t **); 7670Sstevel@tonic-gate int __s_api_getDNs(char ***, const char *, 7680Sstevel@tonic-gate ns_ldap_error_t **); 7690Sstevel@tonic-gate int __s_api_get_search_DNs_v1(char ***, const char *, 7700Sstevel@tonic-gate ns_ldap_error_t **); 7710Sstevel@tonic-gate int __s_api_getConnection(const char *, const int, 7720Sstevel@tonic-gate const ns_cred_t *, int *, 7736842Sth160488 Connection **, ns_ldap_error_t **, int, int, ns_conn_user_t *); 7740Sstevel@tonic-gate char **__s_api_cp2dArray(char **); 7750Sstevel@tonic-gate void __s_api_free2dArray(char **); 7760Sstevel@tonic-gate 7770Sstevel@tonic-gate int __s_api_isCtrlSupported(Connection *, char *); 7780Sstevel@tonic-gate ns_config_t *__ns_ldap_make_config(ns_ldap_result_t *result); 7790Sstevel@tonic-gate ns_auth_t *__s_api_AuthEnumtoStruct(const EnumAuthType_t i); 7806842Sth160488 boolean_t __s_api_peruser_proc(void); 7816842Sth160488 boolean_t __s_api_nscd_proc(void); 7820Sstevel@tonic-gate char *dvalue(char *); 7830Sstevel@tonic-gate char *evalue(char *); 7846842Sth160488 ns_ldap_error_t *__s_api_make_error(int, char *); 7856842Sth160488 ns_ldap_error_t *__s_api_copy_error(ns_ldap_error_t *); 7866842Sth160488 7876842Sth160488 /* ************ specific 'Standalone' functions ********** */ 7886842Sth160488 ns_ldap_return_code __s_api_ip2hostname(char *ipaddr, char **hostname); 7896842Sth160488 struct hostent *__s_api_hostname2ip(const char *name, 7906842Sth160488 struct hostent *result, 7916842Sth160488 char *buffer, 7926842Sth160488 int buflen, 7936842Sth160488 int *h_errnop); 7946842Sth160488 void __s_api_setInitMode(); 7956842Sth160488 void __s_api_unsetInitMode(); 7966842Sth160488 int __s_api_isStandalone(void); 7976842Sth160488 int __s_api_isInitializing(); 7986842Sth160488 ns_ldap_return_code __s_api_findRootDSE(const char *request, 7996842Sth160488 const char *server, 8006842Sth160488 const char *addrType, 8016842Sth160488 ns_server_info_t *ret, 8026842Sth160488 ns_ldap_error_t **error); 8036842Sth160488 ns_config_t *__s_api_create_config_door_str(char *config, 8046842Sth160488 ns_ldap_error_t **errorp); 8050Sstevel@tonic-gate 8060Sstevel@tonic-gate extern void get_environment(); 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate /* internal Param APIs */ 8090Sstevel@tonic-gate int __ns_ldap_setParamValue(ns_config_t *ptr, 8100Sstevel@tonic-gate const ParamIndexType type, 8110Sstevel@tonic-gate const void *data, ns_ldap_error_t **error); 8120Sstevel@tonic-gate int __s_api_get_type(const char *value, ParamIndexType *type); 8130Sstevel@tonic-gate int __s_api_get_versiontype(ns_config_t *ptr, char *value, 8140Sstevel@tonic-gate ParamIndexType *type); 8150Sstevel@tonic-gate int __s_api_get_profiletype(char *value, ParamIndexType *type); 8160Sstevel@tonic-gate void __s_api_init_config(ns_config_t *ptr); 8176842Sth160488 void __s_api_init_config_global(ns_config_t *ptr); 8180Sstevel@tonic-gate ns_parse_status __s_api_crosscheck(ns_config_t *domainptr, char *errstr, 8190Sstevel@tonic-gate int check_dn); 8200Sstevel@tonic-gate ns_config_t *__s_api_create_config(void); 8210Sstevel@tonic-gate ns_config_t *__s_api_get_default_config(void); 8226842Sth160488 ns_config_t *__s_api_get_default_config_global(void); 8230Sstevel@tonic-gate ns_config_t *__s_api_loadrefresh_config(); 8246842Sth160488 ns_config_t *__s_api_loadrefresh_config_global(); 8250Sstevel@tonic-gate void __s_api_destroy_config(ns_config_t *ptr); 8260Sstevel@tonic-gate int __s_api_get_configtype(ParamIndexType type); 8270Sstevel@tonic-gate const char *__s_api_get_configname(ParamIndexType type); 82810132SMilan.Jurik@Sun.COM char *__s_api_strValue(ns_config_t *ptr, ParamIndexType i, 8290Sstevel@tonic-gate ns_strfmt_t fmt); 8300Sstevel@tonic-gate void __s_api_release_config(ns_config_t *cfg); 8310Sstevel@tonic-gate 8320Sstevel@tonic-gate /* internal attribute/objectclass mapping api's */ 8330Sstevel@tonic-gate int __s_api_add_map2hash(ns_config_t *config, 8340Sstevel@tonic-gate ns_hashtype_t type, ns_mapping_t *map); 8350Sstevel@tonic-gate void __s_api_destroy_hash(ns_config_t *config); 8360Sstevel@tonic-gate int __s_api_parse_map(char *cp, char **sid, 8370Sstevel@tonic-gate char **origA, char ***mapA); 8380Sstevel@tonic-gate char **__ns_ldap_mapAttributeList(const char *service, 8390Sstevel@tonic-gate const char * const *origAttrList); 84012758SJulian.Pullen@Sun.COM char *__ns_ldap_mapAttribute(const char *service, 84112758SJulian.Pullen@Sun.COM const char *origAttr); 8420Sstevel@tonic-gate 8430Sstevel@tonic-gate /* internal configuration APIs */ 8440Sstevel@tonic-gate void __ns_ldap_setServer(int set); 8450Sstevel@tonic-gate ns_ldap_error_t *__ns_ldap_LoadConfiguration(); 8466842Sth160488 ns_ldap_error_t *__ns_ldap_LoadDoorInfo(LineBuf *configinfo, char *domainname, 8479576SJulian.Pullen@Sun.COM ns_config_t *new, int cred_only); 8480Sstevel@tonic-gate ns_ldap_error_t *__ns_ldap_DumpConfiguration(char *filename); 8490Sstevel@tonic-gate ns_ldap_error_t *__ns_ldap_DumpLdif(char *filename); 8500Sstevel@tonic-gate int __ns_ldap_cache_ping(); 8512830Sdjl ns_ldap_error_t *__ns_ldap_print_config(int); 8522830Sdjl void __ns_ldap_default_config(); 8532830Sdjl int __ns_ldap_download(const char *, char *, char *, 8542830Sdjl ns_ldap_error_t **); 8552830Sdjl int 8562830Sdjl __ns_ldap_check_dns_preq(int foreground, 8572830Sdjl int mode_verbose, 8582830Sdjl int mode_quiet, 8592830Sdjl const char *fname, 8602830Sdjl ns_ldap_self_gssapi_config_t config, 8612830Sdjl ns_ldap_error_t **errpp); 8622830Sdjl int 8632830Sdjl __ns_ldap_check_gssapi_preq(int foreground, 8642830Sdjl int mode_verbose, 8652830Sdjl int mode_quiet, 8662830Sdjl ns_ldap_self_gssapi_config_t config, 8672830Sdjl ns_ldap_error_t **errpp); 8682830Sdjl int 8692830Sdjl __ns_ldap_check_all_preq(int foreground, 8702830Sdjl int mode_verbose, 8712830Sdjl int mode_quiet, 8722830Sdjl ns_ldap_self_gssapi_config_t config, 8732830Sdjl ns_ldap_error_t **errpp); 8740Sstevel@tonic-gate 8750Sstevel@tonic-gate /* internal un-exposed APIs */ 8760Sstevel@tonic-gate ns_cred_t *__ns_ldap_dupAuth(const ns_cred_t *authp); 8776842Sth160488 boolean_t __s_api_is_auth_matched(const ns_cred_t *auth1, 8786842Sth160488 const ns_cred_t *auth2); 8790Sstevel@tonic-gate int __s_api_get_SSD_from_SSDtoUse_service(const char *service, 8800Sstevel@tonic-gate ns_ldap_search_desc_t ***SSDlist, 8810Sstevel@tonic-gate ns_ldap_error_t **errorp); 8820Sstevel@tonic-gate int __s_api_prepend_automountmapname(const char *service, 8830Sstevel@tonic-gate ns_ldap_search_desc_t ***SSDlist, 8840Sstevel@tonic-gate ns_ldap_error_t ** errorp); 8850Sstevel@tonic-gate int __s_api_prepend_automountmapname_to_dn(const char *service, 8860Sstevel@tonic-gate char **basedn, 8870Sstevel@tonic-gate ns_ldap_error_t ** errorp); 8880Sstevel@tonic-gate int __s_api_convert_automountmapname(const char *service, 8890Sstevel@tonic-gate char **dn, ns_ldap_error_t ** errorp); 8900Sstevel@tonic-gate int __s_api_replace_mapped_attr_in_dn( 8910Sstevel@tonic-gate const char *orig_attr, const char *mapped_attr, 8920Sstevel@tonic-gate const char *dn, char **new_dn); 8930Sstevel@tonic-gate int __s_api_append_default_basedn( 8940Sstevel@tonic-gate const char *dn, 8950Sstevel@tonic-gate char **new_dn, 8960Sstevel@tonic-gate int *allocated, 8970Sstevel@tonic-gate ns_ldap_error_t ** errorp); 898493Ssdussud int __s_api_removeServer(const char *server); 8991687Sjanga void __s_api_removeBadServers(char **server); 9004522Schinlong void __s_api_free_server_info(ns_server_info_t *sinfo); 9016842Sth160488 void __s_api_freeConnection(Connection *con); 9020Sstevel@tonic-gate 9030Sstevel@tonic-gate /* internal referrals APIs */ 9040Sstevel@tonic-gate int __s_api_toFollowReferrals(const int flags, 9050Sstevel@tonic-gate int *toFollow, 9060Sstevel@tonic-gate ns_ldap_error_t **errorp); 9070Sstevel@tonic-gate int __s_api_addRefInfo(ns_referral_info_t **head, 9080Sstevel@tonic-gate char *url, char *baseDN, int *scope, 9090Sstevel@tonic-gate char *filter, LDAP *ld); 9100Sstevel@tonic-gate void __s_api_deleteRefInfo(ns_referral_info_t *head); 9110Sstevel@tonic-gate 9120Sstevel@tonic-gate /* callback routine for SSD filters */ 9130Sstevel@tonic-gate int __s_api_merge_SSD_filter(const ns_ldap_search_desc_t *desc, 9140Sstevel@tonic-gate char **realfilter, 9150Sstevel@tonic-gate const void *userdata); 9160Sstevel@tonic-gate 9170Sstevel@tonic-gate /* network address verification api */ 9180Sstevel@tonic-gate int __s_api_isipv4(char *addr); 9190Sstevel@tonic-gate int __s_api_isipv6(char *addr); 9200Sstevel@tonic-gate int __s_api_ishost(char *addr); 9210Sstevel@tonic-gate 9220Sstevel@tonic-gate /* password management routine */ 9230Sstevel@tonic-gate ns_ldap_passwd_status_t 9240Sstevel@tonic-gate __s_api_set_passwd_status(int errnum, char *errmsg); 9250Sstevel@tonic-gate int __s_api_contain_passwd_control_oid(char **oids); 9260Sstevel@tonic-gate 9271179Svv149972 /* password less account management routine */ 9281179Svv149972 int __s_api_contain_account_usable_control_oid(char **oids); 9291179Svv149972 9300Sstevel@tonic-gate /* RFC 2307 section 5.6. Get a canonical name from entry */ 9310Sstevel@tonic-gate char *__s_api_get_canonical_name(ns_ldap_entry_t *entry, 9320Sstevel@tonic-gate ns_ldap_attr_t *attrptr, int case_ignore); 9330Sstevel@tonic-gate 9342830Sdjl /* self/sasl/gssapi functions */ 9352830Sdjl int __s_api_sasl_bind_callback( 9362830Sdjl LDAP *ld, 9372830Sdjl unsigned flags, 9382830Sdjl void *defaults, 9392830Sdjl void *in); 9402830Sdjl 9412830Sdjl int __s_api_self_gssapi_only_get(void); 9422830Sdjl 94310132SMilan.Jurik@Sun.COM int __print2buf(LineBuf *line, const char *toprint, char *sep); 94410132SMilan.Jurik@Sun.COM 9450Sstevel@tonic-gate #ifdef __cplusplus 9460Sstevel@tonic-gate } 9470Sstevel@tonic-gate #endif 9480Sstevel@tonic-gate 9490Sstevel@tonic-gate #endif /* _NS_INTERNAL_H */ 950