2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _NS_INTERNAL_H
2N/A#define _NS_INTERNAL_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <stdio.h>
2N/A#include <sys/types.h>
2N/A#include <sys/time.h>
2N/A#include <thread.h>
2N/A#include <lber.h>
2N/A#include <ldap.h>
2N/A#include "ns_sldap.h"
2N/A#include "ns_cache_door.h"
2N/A
2N/A/*
2N/A * INTERNALLY USED CONSTANTS
2N/A */
2N/A
2N/A#define MAXERROR 2000
2N/A#define TRUE 1
2N/A#define FALSE 0
2N/A#define NSLDAPDIRECTORY "/var/ldap"
2N/A#define NSCONFIGFILE "/var/ldap/ldap_client_file"
2N/A#define NSCONFIGREFRESH "/var/ldap/ldap_client_file.refresh"
2N/A#define NSCREDFILE "/var/ldap/ldap_client_cred"
2N/A#define NSCREDREFRESH "/var/ldap/ldap_client_cred.refresh"
2N/A#define ROTORSIZE 256
2N/A#define MASK 0377
2N/A#define LDAPMAXHARDLOOKUPTIME 256
2N/A#define DONOTEDIT \
2N/A "Do not edit this file manually; your changes will be lost." \
2N/A "Please use ldapclient (1M) instead."
2N/A#define MAXPORTNUMBER 65535
2N/A#define MAXPORTNUMBER_STR "65535"
2N/A#define CREDFILE 0
2N/A#define CONFIGFILE 1
2N/A#define UIDNUMFILTER "(&(objectclass=posixAccount)(uidnumber=%s))"
2N/A#define UIDNUMFILTER_SSD "(&(%%s)(uidnumber=%s))"
2N/A#define UIDFILTER "(&(objectclass=posixAccount)(uid=%s))"
2N/A#define UIDFILTER_SSD "(&(%%s)(uid=%s))"
2N/A#define HOSTFILTER "(&(objectclass=ipHost)(cn=%s))"
2N/A#define HOSTFILTER_SSD "(&(%%s)(cn=%s))"
2N/A
2N/A#define SIMPLEPAGECTRLFLAG 1
2N/A#define VLVCTRLFLAG 2
2N/A
2N/A#define LISTPAGESIZE 1000
2N/A#define ENUMPAGESIZE 100
2N/A
2N/A#define DEFMAX 8
2N/A#define TOKENSEPARATOR '='
2N/A#define QUOTETOK '"'
2N/A#define SPACETOK ' '
2N/A#define COMMATOK ','
2N/A#define COLONTOK ':'
2N/A#define QUESTTOK '?'
2N/A#define SEMITOK ';'
2N/A#define TABTOK '\t'
2N/A#define OPARATOK '('
2N/A#define CPARATOK ')'
2N/A#define BSLTOK '\\'
2N/A#define DOORLINESEP "\07"
2N/A#define DOORLINESEP_CHR 0x7
2N/A#define COMMASEP ", "
2N/A#define SPACESEP " "
2N/A#define SEMISEP ";"
2N/A#define COLONSEP ":"
2N/A#define COLSPSEP ": "
2N/A#define EQUALSEP "="
2N/A#define EQUSPSEP "= "
2N/A#define LAST_VALUE (int)NS_LDAP_HOST_CERTPATH_P
2N/A#define BUFSIZE BUFSIZ
2N/A#define DEFAULTCONFIGNAME "__default_config"
2N/A#define EXP_DEFAULT_TTL "43200" /* 12 hours TTL */
2N/A#define CRYPTMARK "{NS1}"
2N/A#define DOORBUFFERSIZE 8192
2N/A
2N/A#define LDIF_FMT_STR "%s: %s"
2N/A#define FILE_FMT_STR "%s= %s"
2N/A#define DOOR_FMT_STR "%s=%s"
2N/A
2N/A#define SESSION_CACHE_INC 8
2N/A#define CONID_OFFSET 1024
2N/A#define NS_DEFAULT_BIND_TIMEOUT 30 /* timeout value in seconds */
2N/A#define NS_DEFAULT_SEARCH_TIMEOUT 30 /* timeout value in seconds */
2N/A
2N/A/* max rdn length in conversion routines used by __ns_ldap_addTypedEntry() */
2N/A#define RDNSIZE 512
2N/A
2N/A/*
2N/A * special service used by ldap_cachemgr to indicate a shadow update
2N/A * is to be done with the credential of the administrator identity
2N/A */
2N/A#define NS_ADMIN_SHADOW_UPDATE "shadow__admin_update"
2N/A
2N/A/* Phase 1 profile information */
2N/A#define _PROFILE1_OBJECTCLASS "SolarisNamingProfile"
2N/A#define _PROFILE_CONTAINER "profile"
2N/A#define _PROFILE_FILTER "(&(|(objectclass=%s)(objectclass=%s))(cn=%s))"
2N/A
2N/A/* Phase 2 profile information */
2N/A#define _PROFILE2_OBJECTCLASS "DUAConfigProfile"
2N/A
2N/A/* Common to all profiles */
2N/A#define _P_CN "cn"
2N/A
2N/A/* Native LDAP Phase 1 Specific Profile Attributes */
2N/A#define _P1_SERVERS "SolarisLDAPServers"
2N/A#define _P1_SEARCHBASEDN "SolarisSearchBaseDN"
2N/A#define _P1_CACHETTL "SolarisCacheTTL"
2N/A#define _P1_BINDDN "SolarisBindDN"
2N/A#define _P1_BINDPASSWORD "SolarisBindPassword"
2N/A#define _P1_AUTHMETHOD "SolarisAuthMethod"
2N/A#define _P1_TRANSPORTSECURITY "SolarisTransportSecurity"
2N/A#define _P1_CERTIFICATEPATH "SolarisCertificatePath"
2N/A#define _P1_CERTIFICATEPASSWORD "SolarisCertificatePassword"
2N/A#define _P1_DATASEARCHDN "SolarisDataSearchDN"
2N/A#define _P1_SEARCHSCOPE "SolarisSearchScope"
2N/A#define _P1_SEARCHTIMELIMIT "SolarisSearchTimeLimit"
2N/A#define _P1_PREFERREDSERVER "SolarisPreferredServer"
2N/A#define _P1_PREFERREDSERVERONLY "SolarisPreferredServerOnly"
2N/A#define _P1_SEARCHREFERRAL "SolarisSearchReferral"
2N/A#define _P1_BINDTIMELIMIT "SolarisBindTimeLimit"
2N/A
2N/A/* Native LDAP Phase 2 Specific Profile Attributes */
2N/A#define _P2_PREFERREDSERVER "preferredServerList"
2N/A#define _P2_DEFAULTSERVER "defaultServerList"
2N/A#define _P2_SEARCHBASEDN "defaultSearchBase"
2N/A#define _P2_SEARCHSCOPE "defaultSearchScope"
2N/A#define _P2_AUTHMETHOD "authenticationMethod"
2N/A#define _P2_CREDENTIALLEVEL "credentialLevel"
2N/A#define _P2_SERVICESEARCHDESC "serviceSearchDescriptor"
2N/A#define _P2_SEARCHTIMELIMIT "searchTimeLimit"
2N/A#define _P2_BINDTIMELIMIT "bindTimeLimit"
2N/A#define _P2_FOLLOWREFERRALS "followReferrals"
2N/A#define _P2_PROFILETTL "profileTTL"
2N/A#define _P2_ATTRIBUTEMAP "attributeMap"
2N/A#define _P2_OBJECTCLASSMAP "objectClassMap"
2N/A#define _P2_SERVICECREDLEVEL "serviceCredentialLevel"
2N/A#define _P2_SERVICEAUTHMETHOD "serviceAuthenticationMethod"
2N/A
2N/A/* Control, SASL mechanism, and server information from RootDSE door call */
2N/A#define _SASLMECHANISM "supportedSASLmechanisms"
2N/A#define _SASLMECHANISM_LEN (sizeof (_SASLMECHANISM) - 1)
2N/A#define _SUPPORTEDCONTROL "supportedControl"
2N/A#define _SUPPORTEDCONTROL_LEN (sizeof (_SUPPORTEDCONTROL) - 1)
2N/A#define _ISGLOBALCATALOGREADY "isGlobalCatalogReady"
2N/A#define _OPENLDAPROOTDSE "OpenLDAProotDSE"
2N/A#define _VENDORNAME "vendorName"
2N/A#define _VENDORSUN "Sun Microsystems, Inc."
2N/A
2N/A#define NS_HASH_MAX 257
2N/A#define NS_HASH_SCHEMA_MAPPING_EXISTED "=MAPPING EXISTED="
2N/A#define NS_HASH_RC_SUCCESS 1
2N/A#define NS_HASH_RC_NO_MEMORY -1
2N/A#define NS_HASH_RC_CONFIG_ERROR -2
2N/A#define NS_HASH_RC_EXISTED -3
2N/A#define NS_HASH_RC_SYNTAX_ERROR -4
2N/A
2N/A/* Password management related error message from iDS ldap server */
2N/A#define NS_PWDERR_MAXTRIES \
2N/A "Exceed password retry limit."
2N/A#define NS_PWDERR_EXPIRED \
2N/A "password expired!"
2N/A#define NS_PWDERR_ACCT_INACTIVATED \
2N/A "Account inactivated. Contact system administrator."
2N/A#define NS_PWDERR_CHANGE_NOT_ALLOW \
2N/A "user is not allowed to change password"
2N/A#define NS_PWDERR_INVALID_SYNTAX \
2N/A "invalid password syntax"
2N/A#define NS_PWDERR_TRIVIAL_PASSWD \
2N/A "Password failed triviality check"
2N/A#define NS_PWDERR_IN_HISTORY \
2N/A "password in history"
2N/A#define NS_PWDERR_WITHIN_MIN_AGE \
2N/A "within password minimum age"
2N/A
2N/A/*
2N/A * INTERNALLY USED MACROS
2N/A */
2N/A
2N/Avoid __s_api_debug_pause(int priority, int st, const char *mesg);
2N/A
2N/A#define NULL_OR_STR(str) (!(str) || *(str) == '\0' ? "<NULL>" : (str))
2N/A
2N/A/*
2N/A * MKERROR: builds the error structure and fills in the status and
2N/A * the message. The message must be a freeable (non-static) string.
2N/A * If it fails to allocate memory for the error structure,
2N/A * it will return the retErr.
2N/A */
2N/A#define MKERROR(priority, err, st, mesg, retErr) \
2N/A if (((err) = calloc(1, sizeof (struct ns_ldap_error))) == NULL) \
2N/A return (retErr); \
2N/A (err)->message = mesg; \
2N/A (err)->status = (st); \
2N/A __s_api_debug_pause(priority, st, (err)->message);
2N/A
2N/A/*
2N/A * MKERROR_PWD_MGMT is almost the same as MKERROR
2N/A * except that it takes two more inputs to fill in the
2N/A * password management information part of the
2N/A * ns_ldap_error structure pointed to by err,
2N/A * and it does not log a syslog message.
2N/A */
2N/A#define MKERROR_PWD_MGMT(err, st, mesg, pwd_status, sec_until_exp, retErr) \
2N/A if (((err) = calloc(1, sizeof (struct ns_ldap_error))) == NULL) \
2N/A return (retErr); \
2N/A (err)->message = mesg; \
2N/A (err)->status = (st); \
2N/A (err)->pwd_mgmt.status = (pwd_status); \
2N/A (err)->pwd_mgmt.sec_until_expired = (sec_until_exp);
2N/A
2N/A#ifdef DEBUG
2N/A#define NSLDAPTRACE(variable, setequal, message) \
2N/A if (variable > 0 || ((setequal != 0) && (variable == setequal))) { \
2N/A char buf[BUFSIZ]; \
2N/A (void) snprintf(buf, BUFSIZ, message); \
2N/A (void) write(__ldap_debug_file, buf); \
2N/A }
2N/A#endif
2N/A
2N/A/*
2N/A * INTERNAL DATA STRUCTURES
2N/A */
2N/A
2N/A/*
2N/A * configuration entry type
2N/A */
2N/A
2N/Atypedef enum {
2N/A SERVERCONFIG = 1,
2N/A CLIENTCONFIG = 2,
2N/A CREDCONFIG = 3
2N/A} ns_conftype_t;
2N/A
2N/A/*
2N/A * datatype of a config entry
2N/A */
2N/A
2N/Atypedef enum {
2N/A NS_UNKNOWN = 0,
2N/A CHARPTR = 1, /* Single character pointer */
2N/A ARRAYCP = 2, /* comma sep array of char pointers */
2N/A ARRAYAUTH = 3, /* Array of auths */
2N/A TIMET = 4, /* time relative value (TTL) */
2N/A INT = 5, /* single integer */
2N/A SSDLIST = 6, /* service search descriptor */
2N/A ATTRMAP = 7, /* attribute mapping */
2N/A OBJMAP = 8, /* objectclass mapping */
2N/A SERVLIST = 9, /* serverlist (SP sep array) */
2N/A ARRAYCRED = 10, /* Array of credentialLevels */
2N/A SAMLIST = 11, /* serviceAuthenticationMethod */
2N/A SCLLIST = 12 /* serviceCredentialLevel */
2N/A} ns_datatype_t;
2N/A
2N/Atypedef enum {
2N/A NS_SUCCESS,
2N/A NS_NOTFOUND,
2N/A NS_PARSE_ERR
2N/A} ns_parse_status;
2N/A
2N/Atypedef enum {
2N/A NS_DOOR_FMT = 1,
2N/A NS_LDIF_FMT = 2,
2N/A NS_FILE_FMT = 3
2N/A} ns_strfmt_t;
2N/A
2N/A/*
2N/A * This enum reduces the number of version string compares
2N/A * against NS_LDAP_VERSION_1 and NS_LDAP_VERSION_2
2N/A */
2N/A
2N/Atypedef enum {
2N/A NS_LDAP_V1 = 1000,
2N/A NS_LDAP_V2 = 2000
2N/A} ns_version_t;
2N/A
2N/A/*
2N/A * enum<->string mapping construct
2N/A */
2N/A
2N/Atypedef struct ns_enum_map {
2N/A int value;
2N/A char *name;
2N/A} ns_enum_map;
2N/A
2N/A#define ENUM2INT(x) ((int)(x))
2N/A
2N/A#define INT2PARAMINDEXENUM(x) ((ParamIndexType)(x))
2N/A#define INT2SEARCHREFENUM(x) ((SearchRef_t)(x))
2N/A#define INT2SCOPEENUM(x) ((ScopeType_t)(x))
2N/A#define INT2AUTHENUM(x) ((AuthType_t)(x))
2N/A#define INT2SECENUM(x) ((TlsType_t)(x))
2N/A#define INT2PREFONLYENUM(x) ((PrefOnly_t)(x))
2N/A#define INT2CREDLEVELENUM(x) ((CredLevel_t)(x))
2N/A#define INT2SHADOWUPDATENUM(x) ((enableShadowUpdate_t)(x))
2N/A
2N/A#define INT2LDAPRETURN(x) ((ns_ldap_return_code)(x))
2N/A#define INT2CONFIGRETURN(x) ((ns_ldap_config_return_code)(x))
2N/A#define INT2PARTIALRETURN(x) ((ns_ldap_partial_return_code)(x))
2N/A
2N/A/*
2N/A * This structure maps service name to rdn components
2N/A * for use in __ns_getDNs. It also defines the SSD-to-use
2N/A * service for use in __s_api_get_SSDtoUse_service.
2N/A * The idea of an SSD-to-use service is to reduce the configuration
2N/A * complexity. For a service, which does not have its own entries in
2N/A * the LDAP directory, SSD for it is useless, and should not be set.
2N/A * But since this service must share the container with at least
2N/A * one other service which does have it own entries, the SSD for
2N/A * this other service will be shared by this service.
2N/A * This other service is called the SSD-to-use service.
2N/A *
2N/A */
2N/A
2N/Atypedef struct ns_service_map {
2N/A char *service;
2N/A char *rdn;
2N/A char *SSDtoUse_service;
2N/A} ns_service_map;
2N/A
2N/A/*
2N/A * This structure contains a single mapping from:
2N/A * service:orig -> list of mapped
2N/A */
2N/A
2N/Atypedef enum {
2N/A NS_ATTR_MAP,
2N/A NS_OBJ_MAP
2N/A} ns_maptype_t;
2N/A
2N/Atypedef struct ns_mapping {
2N/A ns_maptype_t type;
2N/A char *service;
2N/A char *orig;
2N/A char **map;
2N/A} ns_mapping_t;
2N/A
2N/A/*
2N/A * The following is the list of internal libsldap configuration data
2N/A * structures. The configuration is populated normally once per
2N/A * application. The assumption is that in applications can be
2N/A * relatively short lived (IE ls via nsswitch) so it is important to
2N/A * keep configuration to a minimum, but keep lookups fast.
2N/A *
2N/A * Assumptions:
2N/A * 1 configuration entry per domain, and almost always 1 domain
2N/A * per app. Hooks exist for multiple domains per app.
2N/A *
2N/A * Configurations are read in from client file cache or from LDAP.
2N/A * Attribute/objectclass mappings are hashed to improve lookup
2N/A * speed.
2N/A */
2N/A
2N/A/*
2N/A * Hash entry types
2N/A */
2N/Atypedef enum _ns_hashtype_t {
2N/A NS_HASH_AMAP = 1, /* attr map */
2N/A NS_HASH_RAMAP = 2, /* reverse attr map */
2N/A NS_HASH_OMAP = 3, /* oc map */
2N/A NS_HASH_ROMAP = 4, /* reverse oc map */
2N/A NS_HASH_VOID = 5
2N/A} ns_hashtype_t;
2N/A
2N/Atypedef struct ns_hash {
2N/A ns_hashtype_t h_type;
2N/A ns_mapping_t *h_map;
2N/A struct ns_hash *h_next;
2N/A struct ns_hash *h_llnext;
2N/A} ns_hash_t;
2N/A
2N/A/*
2N/A * This structure defines the format of an internal configuration
2N/A * parameter for ns_ldap client.
2N/A */
2N/A
2N/Atypedef struct ns_param {
2N/A ns_datatype_t ns_ptype;
2N/A int ns_acnt;
2N/A union {
2N/A char **ppc;
2N/A int *pi;
2N/A char *pc;
2N/A int i;
2N/A time_t tm;
2N/A } ns_pu;
2N/A} ns_param_t;
2N/A
2N/A#define ns_ppc ns_pu.ppc
2N/A#define ns_pi ns_pu.pi
2N/A#define ns_pc ns_pu.pc
2N/A#define ns_i ns_pu.i
2N/A#define ns_tm ns_pu.tm
2N/A
2N/A/*
2N/A * This structure defines an instance of a configuration structure.
2N/A * paramList contains the current ns_ldap parameter configuration
2N/A * and hashTbl contain the current attribute/objectclass mappings.
2N/A * Parameters are indexed by using the value assigned to the parameter
2N/A * in ParamIndexType.
2N/A */
2N/A
2N/Atypedef struct ns_config {
2N/A char *domainName;
2N/A ns_version_t version;
2N/A ns_param_t paramList[NS_LDAP_MAX_PIT_P];
2N/A ns_hash_t *hashTbl[NS_HASH_MAX];
2N/A ns_hash_t *llHead;
2N/A ns_ldap_entry_t *RootDSE;
2N/A boolean_t delete;
2N/A mutex_t config_mutex;
2N/A int nUse;
2N/A ldap_get_chg_cookie_t config_cookie;
2N/A} ns_config_t;
2N/A
2N/A/*
2N/A * This structure defines the mapping of the NSCONFIGFILE file
2N/A * statements into their corresponding SolarisNamingProfile,
2N/A * Posix Mapping LDAP attributes, and to their corresponding
2N/A * ParamIndexType enum mapping. THe ParamIndexType enum
2N/A * definitions can be found in ns_ldap.h. This structure also
2N/A * defines the default values that are used when a value either
2N/A * does not exist or is undefined.
2N/A */
2N/A
2N/Atypedef struct ns_default_config {
2N/A const char *name; /* config file parameter name */
2N/A ParamIndexType index; /* config file enum index */
2N/A ns_conftype_t config_type; /* CLIENT/SERVER/CREDCONFIG */
2N/A ns_datatype_t data_type; /* ppc,pi,pc,int etc... */
2N/A int single_valued; /* TRUE OR FALSE */
2N/A ns_version_t version; /* Version # for attribute */
2N/A const char *profile_name; /* profile schema attribute name */
2N/A ns_param_t defval; /* config file parameter default */
2N/A int (*ns_verify)(ParamIndexType i,
2N/A struct ns_default_config *def,
2N/A ns_param_t *param,
2N/A char *errbuf);
2N/A ns_enum_map *allowed; /* allowed values */
2N/A} ns_default_config;
2N/A
2N/A
2N/A/*
2N/A * This typedef enumerates all the supported authentication
2N/A * mechanisms currently supported in this library
2N/A */
2N/A
2N/Atypedef enum EnumAuthType {
2N/A NS_LDAP_EA_NONE = 0,
2N/A NS_LDAP_EA_SIMPLE = 1,
2N/A NS_LDAP_EA_SASL_NONE = 2,
2N/A NS_LDAP_EA_SASL_CRAM_MD5 = 3,
2N/A NS_LDAP_EA_SASL_DIGEST_MD5 = 4,
2N/A NS_LDAP_EA_SASL_DIGEST_MD5_INT = 5,
2N/A NS_LDAP_EA_SASL_DIGEST_MD5_CONF = 6,
2N/A NS_LDAP_EA_SASL_EXTERNAL = 7,
2N/A NS_LDAP_EA_SASL_GSSAPI = 8,
2N/A NS_LDAP_EA_SASL_SPNEGO = 9, /* unsupported */
2N/A NS_LDAP_EA_TLS_NONE = 10,
2N/A NS_LDAP_EA_TLS_SIMPLE = 11,
2N/A NS_LDAP_EA_TLS_SASL_NONE = 12,
2N/A NS_LDAP_EA_TLS_SASL_CRAM_MD5 = 13,
2N/A NS_LDAP_EA_TLS_SASL_DIGEST_MD5 = 14,
2N/A NS_LDAP_EA_TLS_SASL_DIGEST_MD5_INT = 15,
2N/A NS_LDAP_EA_TLS_SASL_DIGEST_MD5_CONF = 16,
2N/A NS_LDAP_EA_TLS_SASL_EXTERNAL = 17,
2N/A NS_LDAP_EA_TLS_SASL_GSSAPI = 18, /* unsupported */
2N/A NS_LDAP_EA_TLS_SASL_SPNEGO = 19 /* unsupported */
2N/A} EnumAuthType_t;
2N/A
2N/A
2N/A/*
2N/A * this enum lists the various states of the search state machine
2N/A */
2N/A
2N/Atypedef enum {
2N/A INIT = 1,
2N/A EXIT = 2,
2N/A NEXT_SEARCH_DESCRIPTOR = 3,
2N/A GET_SESSION = 4,
2N/A NEXT_SESSION = 5,
2N/A RESTART_SESSION = 6,
2N/A NEXT_SEARCH = 7,
2N/A NEXT_VLV = 8,
2N/A NEXT_PAGE = 9,
2N/A ONE_SEARCH = 10,
2N/A DO_SEARCH = 11,
2N/A NEXT_RESULT = 12,
2N/A MULTI_RESULT = 13,
2N/A PROCESS_RESULT = 14,
2N/A END_PROCESS_RESULT = 15,
2N/A END_RESULT = 16,
2N/A NEXT_REFERRAL = 17,
2N/A GET_REFERRAL_SESSION = 18,
2N/A ERROR = 19,
2N/A LDAP_ERROR = 20,
2N/A GET_ACCT_MGMT_INFO = 21,
2N/A CLEAR_RESULTS = 22,
2N/A REINIT = 23,
2N/A NEXT_RANGE = 24,
2N/A NEXT_RANGE_RESULT = 25,
2N/A NEXT_RANGE_RESTORE = 26,
2N/A DROP_SESSION = 27,
2N/A RESULT_ERROR = 28
2N/A} ns_state_t;
2N/A
2N/A/*
2N/A * this enum lists the various states of the write state machine
2N/A */
2N/Atypedef enum {
2N/A W_INIT = 1,
2N/A W_EXIT = 2,
2N/A GET_CONNECTION = 3,
2N/A SELECT_OPERATION_SYNC = 4,
2N/A SELECT_OPERATION_ASYNC = 5,
2N/A DO_ADD_SYNC = 6,
2N/A DO_DELETE_SYNC = 7,
2N/A DO_MODIFY_SYNC = 8,
2N/A DO_ADD_ASYNC = 9,
2N/A DO_DELETE_ASYNC = 10,
2N/A DO_MODIFY_ASYNC = 11,
2N/A GET_RESULT_SYNC = 12,
2N/A GET_RESULT_ASYNC = 13,
2N/A PARSE_RESULT = 14,
2N/A GET_REFERRAL_CONNECTION = 15,
2N/A W_LDAP_ERROR = 16,
2N/A W_ERROR = 17
2N/A} ns_write_state_t;
2N/A
2N/A
2N/Atypedef int ConnectionID;
2N/A
2N/A/*
2N/A * Server side sort type. Orginally the server side sort
2N/A * was set to "cn uid". This did not work with AD and
2N/A * hence single sort attribute was odopted. We dont
2N/A * know which server side sort will work with the
2N/A * Directory and hence we discover which method works.
2N/A */
2N/Atypedef enum {
2N/A SSS_UNKNOWN = 0,
2N/A SSS_SINGLE_ATTR = 1,
2N/A SSS_CN_UID_ATTRS = 2
2N/A} ns_srvsidesort_t;
2N/A
2N/A/*
2N/A * This structure is used by ns_connect to create and manage
2N/A * one or more ldap connections within the library.
2N/A */
2N/Atypedef struct connection {
2N/A ConnectionID connectionId;
2N/A boolean_t usedBit; /* true if only used by */
2N/A /* one thread and not shared */
2N/A /* by other threads */
2N/A pid_t pid; /* process id */
2N/A char *serverAddr;
2N/A ns_cred_t *auth;
2N/A LDAP *ld;
2N/A thread_t threadID; /* thread ID using it */
2N/A struct ns_ldap_cookie *cookieInfo;
2N/A char **controls; /* from server_info */
2N/A char **saslMechanisms; /* from server_info */
2N/A ns_ldap_server_type_t serverType; /* from server_info */
2N/A} Connection;
2N/A
2N/A#define ONE_STEP 1
2N/A
2N/A
2N/A/*
2N/A * These structures are for referral processing.
2N/A * The referrals are returned to the LDAP client
2N/A * from an LDAP server.
2N/A *
2N/A * A referral can have many ref values. Each ref is a URL
2N/A * which provides information to continue an LDAP operation.
2N/A * If a referral contains more than one ref then any
2N/A * ref can be used to continue the LDAP operation.
2N/A * Multiple refs are normally used to supply
2N/A * alternative directory servers for failover.
2N/A */
2N/A
2N/Atypedef struct ns_referral {
2N/A struct ns_referral *next;
2N/A struct ns_ref_info *ref;
2N/A} ns_referral_t;
2N/A
2N/Atypedef struct ns_ref_info {
2N/A struct ns_ref_info *next;
2N/A char *refHost;
2N/A int refScope;
2N/A char *refDN;
2N/A char *refFilter;
2N/A} ns_ref_info_t;
2N/A
2N/A
2N/A#define NS_LDAP_ATTR_AND_RANGE_SIZE 96
2N/A/*
2N/A * ns_ldap_range_attr_t is used to track the
2N/A * processing of attributes returned in LDAP
2N/A * search results that contain range option
2N/A * specification, which is in the form:
2N/A * <attr name>;range=n1-n2: <value>
2N/A * For example, "member;range=0-1499: dn0" or
2N/A * "member;range=1500-*: dn1500".
2N/A *
2N/A * It's created when handling an attribute name
2N/A * that contains a range option specification.
2N/A * Servers set n2 to '*' to indicate the end of
2N/A * range. 'range_done' will be set to TRUE when
2N/A * n2 is '*'. If n2 is not '*', 'attr_and_range'
2N/A * will be set for subsequent searches. Its value
2N/A * will be set to "<attr name>;range=n3-*", where
2N/A * n3 = n2+1. '*' is used to ask the server to send
2N/A * as many values as possible. It will be used as
2N/A * the attribute value in the attribute array for
2N/A * the next ldap search.
2N/A *
2N/A * 'received_ranges' holds the first range of attribute
2N/A * values received from the original search, and then
2N/A * is appended with values from subsequent searches.
2N/A * 'current_range' holds the attribute values of the
2N/A * most current search.
2N/A *
2N/A * An attribute name may be mapped due to schema
2N/A * mapping. 'mapped_name' points to the mapped string
2N/A * if any. 'attr_len' is the length of the unmapped
2N/A * attribute name. 'next' points the structure tracking
2N/A * the next range attribute.
2N/A */
2N/Atypedef struct ns_ldap_range_attr {
2N/A boolean_t range_done;
2N/A char *mapped_name;
2N/A char *attr_and_range;
2N/A int attr_len;
2N/A ns_ldap_attr_t *received_ranges;
2N/A ns_ldap_attr_t *current_range;
2N/A struct ns_ldap_range_attr *next;
2N/A} ns_ldap_range_attr_t;
2N/A
2N/A/*
2N/A * ns_ldap_range_info_t are for handling result
2N/A * entries that have attributes with range option.
2N/A * 'attr_count' is the number of such attributes
2N/A * found in a search result entry. 'dn' is the
2N/A * distinguished name of that entry.
2N/A * 'attr_to_search' is the list of attributes
2N/A * for subsequent searches. 'range_attr' points
2N/A * to the ns_ldap_range_attr_t list that tracks
2N/A * these attributes.
2N/A */
2N/Atypedef struct ns_ldap_range_info {
2N/A int attr_count;
2N/A char *dn;
2N/A char **attr_to_search;
2N/A ns_ldap_range_attr_t *range_attr;
2N/A} ns_ldap_range_info_t;
2N/A
2N/Astruct ns_ldap_cookie;
2N/A
2N/A/*
2N/A * Batch used by __ns_ldap_list_batch_xxx API
2N/A */
2N/Astruct ns_ldap_list_batch {
2N/A uint32_t nactive;
2N/A struct ns_ldap_cookie *next_cookie;
2N/A struct ns_ldap_cookie *cookie_list;
2N/A};
2N/A
2N/Astruct ns_conn_user;
2N/Atypedef struct ns_conn_user ns_conn_user_t;
2N/A
2N/A/*
2N/A * This structure used internally in searches
2N/A */
2N/A
2N/Atypedef struct ns_ldap_cookie {
2N/A /* INPUTS */
2N/A /* server list position */
2N/A
2N/A /* service search descriptor list & position */
2N/A ns_ldap_search_desc_t **sdlist;
2N/A ns_ldap_search_desc_t **sdpos;
2N/A
2N/A /* search filter callback */
2N/A int use_filtercb;
2N/A int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
2N/A char **realfilter, const void *userdata);
2N/A
2N/A /* user callback */
2N/A int use_usercb;
2N/A int (*callback)(const ns_ldap_entry_t *entry,
2N/A const void *userdata);
2N/A const void *userdata;
2N/A
2N/A int followRef;
2N/A int use_paging;
2N/A char *service;
2N/A char *i_filter;
2N/A const char * const *i_attr;
2N/A /*
2N/A * i_extra_info_attr tracks the libsldap operational attributes
2N/A * requested. See ns_sldap.h for information about these attributes.
2N/A */
2N/A const char * const *i_extra_info_attr;
2N/A const char *i_sortattr;
2N/A const ns_cred_t *i_auth;
2N/A int i_flags;
2N/A
2N/A /* OUTPUTS */
2N/A ns_ldap_result_t *result;
2N/A /*
2N/A * extra_info contains the libsldap operational attributes
2N/A * requested.
2N/A */
2N/A ns_ldap_entry_t *extra_info;
2N/A ns_ldap_entry_t *nextEntry;
2N/A /* Error data */
2N/A int err_rc;
2N/A ns_ldap_error_t *errorp;
2N/A
2N/A /* PRIVATE */
2N/A ns_state_t state;
2N/A ns_state_t new_state;
2N/A ns_state_t next_state;
2N/A
2N/A Connection *conn;
2N/A#define conn_auth_type conn->auth->auth.type
2N/A ConnectionID connectionId;
2N/A
2N/A /* paging VLV/SIMPLEPAGE data */
2N/A int listType;
2N/A unsigned long index;
2N/A LDAPControl **p_serverctrls;
2N/A ns_srvsidesort_t sortTypeTry;
2N/A int entryCount;
2N/A
2N/A int scope;
2N/A char *basedn;
2N/A char *filter;
2N/A char **attribute;
2N/A
2N/A /* RESULT PROCESSING */
2N/A int msgId;
2N/A LDAPMessage *resultMsg;
2N/A
2N/A char **dns;
2N/A char *currentdn;
2N/A int flag;
2N/A struct berval *ctrlCookie;
2N/A
2N/A /* REFERRALS PROCESSING */
2N/A /* referral list & position */
2N/A ns_referral_t *referral_list;
2N/A ns_referral_t *referral_pos;
2N/A /* Current ref_info of a referral */
2N/A ns_ref_info_t *ref_info;
2N/A
2N/A /* search timeout value */
2N/A struct timeval search_timeout;
2N/A /* response control to hold account management information */
2N/A LDAPControl **resultctrl;
2N/A /* Flag to indicate password less account management is required */
2N/A int nopasswd_acct_mgmt;
2N/A int err_from_result;
2N/A ns_conn_user_t *conn_user;
2N/A
2N/A /* BATCH PROCESSING */
2N/A ns_ldap_list_batch_t *batch;
2N/A boolean_t no_wait;
2N/A boolean_t reinit_on_retriable_err;
2N/A int retries;
2N/A ns_ldap_result_t **caller_result;
2N/A ns_ldap_error_t **caller_errorp;
2N/A int *caller_rc;
2N/A struct ns_ldap_cookie *next_cookie_in_batch;
2N/A
2N/A /* PARTIAL/RANGE RESULT PROCESSING */
2N/A boolean_t get_next_range;
2N/A ns_ldap_range_info_t *range_info;
2N/A} ns_ldap_cookie_t;
2N/A
2N/A/*
2N/A * This structure is part of the return value information for
2N/A * __s_api_requestServer. The routine that requests a new server
2N/A * from the cache manager
2N/A */
2N/Atypedef struct ns_server_info {
2N/A char *server;
2N/A ns_ldap_server_type_t serverType;
2N/A char *serverFQDN;
2N/A char **controls;
2N/A char **saslMechanisms;
2N/A} ns_server_info_t;
2N/A
2N/A/*
2N/A * sasl callback function parameters
2N/A */
2N/Atypedef struct ns_sasl_cb_param {
2N/A char *mech;
2N/A char *authid;
2N/A char *authzid;
2N/A char *passwd;
2N/A char *realm;
2N/A} ns_sasl_cb_param_t;
2N/A
2N/A/* self/sasl/gssapi variable */
2N/Aextern int sasl_gssapi_inited;
2N/A
2N/A/* Multiple threads per connection variable */
2N/Aextern int MTperConn;
2N/A
2N/A/*
2N/A * INTERNAL GLOBAL DEFINITIONS AND FUNCTION DECLARATIONS
2N/A */
2N/A
2N/A#ifdef DEBUG
2N/Aextern int __ldap_debug_file;
2N/Aextern int __ldap_debug_api;
2N/Aextern int __ldap_debug_ldap;
2N/Aextern int __ldap_debug_servers;
2N/A#endif
2N/A
2N/A/* internal connection APIs */
2N/Avoid DropConnection(ConnectionID, int);
2N/Aint __s_api_getServers(char *** servers, ns_ldap_error_t ** error);
2N/A
2N/Aint __s_get_enum_value(ns_config_t *ptr, char *value, ParamIndexType i);
2N/Achar *__s_get_auth_name(ns_config_t *ptr, AuthType_t type);
2N/Achar *__s_get_security_name(ns_config_t *ptr, TlsType_t type);
2N/Achar *__s_get_scope_name(ns_config_t *ptr, ScopeType_t type);
2N/Achar *__s_get_pref_name(PrefOnly_t type);
2N/Achar *__s_get_searchref_name(ns_config_t *ptr, SearchRef_t type);
2N/Achar *__s_get_shadowupdate_name(enableShadowUpdate_t type);
2N/Achar *__s_get_hostcertpath(void);
2N/Avoid __s_api_free_sessionPool(void);
2N/Aint __s_api_requestServer(const char *request, const char *server,
2N/A ns_server_info_t *ret, ns_ldap_error_t **error, const char *addrType);
2N/A
2N/A
2N/A/* ************ internal sldap-api functions *********** */
2N/Avoid __s_api_split_key_value(char *buffer, char **name, char **value);
2N/Aint __s_api_printResult(ns_ldap_result_t *);
2N/Aint __s_api_getSearchScope(int *, ns_ldap_error_t **);
2N/Aint __s_api_getDNs(char ***, const char *,
2N/A ns_ldap_error_t **);
2N/Aint __s_api_get_search_DNs_v1(char ***, const char *,
2N/A ns_ldap_error_t **);
2N/Aint __s_api_getConnection(const char *, const int,
2N/A const ns_cred_t *, int *,
2N/A Connection **, ns_ldap_error_t **, int, int, ns_conn_user_t *);
2N/Achar **__s_api_cp2dArray(char **);
2N/Avoid __s_api_free2dArray(char **);
2N/A
2N/Aint __s_api_isCtrlSupported(Connection *, char *);
2N/Ans_config_t *__ns_ldap_make_config(ns_ldap_result_t *result);
2N/Ans_auth_t *__s_api_AuthEnumtoStruct(const EnumAuthType_t i);
2N/Aboolean_t __s_api_peruser_proc(void);
2N/Aboolean_t __s_api_nscd_proc(void);
2N/Achar *dvalue(char *);
2N/Achar *evalue(char *);
2N/Ans_ldap_error_t *__s_api_make_error(int, char *);
2N/Ans_ldap_error_t *__s_api_copy_error(ns_ldap_error_t *);
2N/A
2N/A/* ************ specific 'Standalone' functions ********** */
2N/Ans_ldap_return_code __s_api_ip2hostname(char *ipaddr, char **hostname);
2N/Astruct hostent *__s_api_hostname2ip(const char *name,
2N/A struct hostent *result,
2N/A char *buffer,
2N/A int buflen,
2N/A int *h_errnop);
2N/Avoid __s_api_setInitMode(void);
2N/Avoid __s_api_unsetInitMode(void);
2N/Aint __s_api_isStandalone(void);
2N/Aint __s_api_isInitializing(void);
2N/Ans_ldap_return_code __s_api_findRootDSE(const char *request,
2N/A const char *server,
2N/A const char *addrType,
2N/A ns_server_info_t *ret,
2N/A ns_ldap_error_t **error);
2N/Ans_config_t *__s_api_create_config_door_str(char *config,
2N/A ns_ldap_error_t **errorp);
2N/A
2N/Aextern void get_environment(void);
2N/A
2N/A/* internal Param APIs */
2N/Aint __ns_ldap_setParamValue(ns_config_t *ptr,
2N/A const ParamIndexType type,
2N/A const void *data, ns_ldap_error_t **error);
2N/Aint __s_api_get_type(const char *value, ParamIndexType *type);
2N/Aint __s_api_get_versiontype(ns_config_t *ptr, char *value,
2N/A ParamIndexType *type);
2N/Aint __s_api_get_profiletype(char *value, ParamIndexType *type);
2N/Avoid __s_api_init_config(ns_config_t *ptr);
2N/Avoid __s_api_init_config_global(ns_config_t *ptr);
2N/Ans_parse_status __s_api_crosscheck(ns_config_t *domainptr, char *errstr,
2N/A boolean_t check_dn, boolean_t check_admin);
2N/Ans_config_t *__s_api_create_config(void);
2N/Ans_config_t *__s_api_get_default_config(void);
2N/Ans_config_t *__s_api_get_default_config_global(void);
2N/Ans_config_t *__s_api_loadrefresh_config(void);
2N/Ans_config_t *__s_api_loadrefresh_config_global(void);
2N/Avoid __s_api_destroy_config(ns_config_t *ptr);
2N/Aint __s_api_get_configtype(ParamIndexType type);
2N/Aconst char *__s_api_get_configname(ParamIndexType type);
2N/Achar *__s_api_strValue(ns_config_t *ptr, ParamIndexType i,
2N/A ns_strfmt_t fmt);
2N/Avoid __s_api_release_config(ns_config_t *cfg);
2N/A
2N/A/* internal attribute/objectclass mapping api's */
2N/Aint __s_api_add_map2hash(ns_config_t *config,
2N/A ns_hashtype_t type, ns_mapping_t *map);
2N/Avoid __s_api_destroy_hash(ns_config_t *config);
2N/Aint __s_api_parse_map(char *cp, char **sid,
2N/A char **origA, char ***mapA);
2N/Achar **__ns_ldap_mapAttributeList(const char *service,
2N/A const char * const *origAttrList);
2N/Achar *__ns_ldap_mapAttribute(const char *service,
2N/A const char *origAttr);
2N/A
2N/A/* internal configuration APIs */
2N/Avoid __ns_ldap_setServer(int set);
2N/Ans_ldap_error_t *__ns_ldap_LoadConfiguration(void);
2N/Ans_ldap_error_t *__ns_ldap_LoadDoorInfo(LineBuf *configinfo, char *domainname,
2N/A ns_config_t *new, int cred_only);
2N/Ans_ldap_error_t *__ns_ldap_DumpConfiguration(char *filename);
2N/Ans_ldap_error_t *__ns_ldap_DumpLdif(char *filename);
2N/Aint __ns_ldap_cache_ping(void);
2N/Ans_ldap_error_t *__ns_ldap_print_config(int);
2N/Avoid __ns_ldap_default_config(void);
2N/Aint __ns_ldap_download(const char *, char *, char *,
2N/A ns_ldap_error_t **);
2N/Aint
2N/A__ns_ldap_check_dns_preq(int foreground,
2N/A int mode_verbose,
2N/A int mode_quiet,
2N/A const char *fname,
2N/A ns_ldap_self_gssapi_config_t config,
2N/A ns_ldap_error_t **errpp);
2N/Aint
2N/A__ns_ldap_check_gssapi_preq(int foreground,
2N/A int mode_verbose,
2N/A int mode_quiet,
2N/A ns_ldap_self_gssapi_config_t config,
2N/A ns_ldap_error_t **errpp);
2N/Aint
2N/A__ns_ldap_check_all_preq(int foreground,
2N/A int mode_verbose,
2N/A int mode_quiet,
2N/A ns_ldap_self_gssapi_config_t config,
2N/A ns_ldap_error_t **errpp);
2N/A
2N/A/* internal un-exposed APIs */
2N/Ans_cred_t *__ns_ldap_dupAuth(const ns_cred_t *authp);
2N/Aboolean_t __s_api_is_auth_matched(const ns_cred_t *auth1,
2N/A const ns_cred_t *auth2);
2N/Aint __s_api_get_SSD_from_SSDtoUse_service(const char *service,
2N/A ns_ldap_search_desc_t ***SSDlist,
2N/A ns_ldap_error_t **errorp);
2N/Aint __s_api_prepend_automountmapname(const char *service,
2N/A ns_ldap_search_desc_t ***SSDlist,
2N/A ns_ldap_error_t ** errorp);
2N/Aint __s_api_prepend_automountmapname_to_dn(const char *service,
2N/A char **basedn,
2N/A ns_ldap_error_t ** errorp);
2N/Aint __s_api_convert_automountmapname(const char *service,
2N/A char **dn, ns_ldap_error_t ** errorp);
2N/Aint __s_api_replace_mapped_attr_in_dn(
2N/A const char *orig_attr, const char *mapped_attr,
2N/A const char *dn, char **new_dn);
2N/Aint __s_api_append_default_basedn(
2N/A const char *dn,
2N/A char **new_dn,
2N/A int *allocated,
2N/A ns_ldap_error_t ** errorp);
2N/Aint __s_api_removeServer(const char *server);
2N/Avoid __s_api_removeBadServers(char **server);
2N/Avoid __s_api_free_server_info(ns_server_info_t *sinfo);
2N/Avoid __s_api_freeConnection(Connection *con);
2N/Aint __s_api_getLdapResult(LDAP *ld, int msgid, int all,
2N/A struct timeval *timeout, LDAPMessage **result);
2N/A
2N/A/* internal referrals APIs */
2N/Aint __s_api_toFollowReferrals(const int flags,
2N/A int *toFollow,
2N/A ns_ldap_error_t **errorp);
2N/Aint __s_api_addReferral(ns_referral_t **head,
2N/A char **urls, char *baseDN, int *scope,
2N/A char *filter, LDAP *ld);
2N/Avoid __s_api_deleteReferral(ns_referral_t *head);
2N/A
2N/A/* callback routine for SSD filters */
2N/Aint __s_api_merge_SSD_filter(const ns_ldap_search_desc_t *desc,
2N/A char **realfilter,
2N/A const void *userdata);
2N/A
2N/A/* network address verification api */
2N/Aint __s_api_isipv4(char *addr);
2N/Aint __s_api_isipv6(char *addr);
2N/Aint __s_api_ishost(char *addr);
2N/A
2N/A/* password management routine */
2N/Ans_ldap_passwd_status_t
2N/A __s_api_set_passwd_status(int errnum, char *errmsg);
2N/Aint __s_api_contain_passwd_control_oid(char **oids);
2N/A
2N/A/* password less account management routine */
2N/Aint __s_api_contain_account_usable_control_oid(char **oids);
2N/A
2N/A/* RFC 2307 section 5.6. Get a canonical name from entry */
2N/Achar *__s_api_get_canonical_name(ns_ldap_entry_t *entry,
2N/A ns_ldap_attr_t *attrptr, int case_ignore);
2N/A
2N/A/* self/sasl/gssapi functions */
2N/Aint __s_api_sasl_bind_callback(
2N/A LDAP *ld,
2N/A unsigned flags,
2N/A void *defaults,
2N/A void *in);
2N/A
2N/Aint __s_api_self_gssapi_only_get(void);
2N/Aint __s_api_sasl_gssapi_init(void);
2N/A
2N/Aint __print2buf(LineBuf *line, const char *toprint, char *sep);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _NS_INTERNAL_H */