1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_NIS_PARSE_LDAP_CONF_H
28*7c478bd9Sstevel@tonic-gate #define	_NIS_PARSE_LDAP_CONF_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
31*7c478bd9Sstevel@tonic-gate extern "C" {
32*7c478bd9Sstevel@tonic-gate #endif
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #include <lber.h>
35*7c478bd9Sstevel@tonic-gate #include <ldap.h>
36*7c478bd9Sstevel@tonic-gate #include <iso/limits_iso.h>
37*7c478bd9Sstevel@tonic-gate #include "ldap_parse.h"
38*7c478bd9Sstevel@tonic-gate #include "nisdb_ldap.h"
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #define	DEFAULT_MAPPING_FILE	"/var/nis/NIS+LDAPmapping"
41*7c478bd9Sstevel@tonic-gate #define	YP_DEFAULT_MAPPING_FILE	"/var/yp/NISLDAPmapping"
42*7c478bd9Sstevel@tonic-gate #define	mmt_berstring_null	((__nis_mapping_match_type_t)-1)
43*7c478bd9Sstevel@tonic-gate #define	ESCAPE_CHAR		'\\'
44*7c478bd9Sstevel@tonic-gate #define	EQUAL_CHAR		'='
45*7c478bd9Sstevel@tonic-gate #define	COMMA_CHAR		','
46*7c478bd9Sstevel@tonic-gate #define	COMMA_STRING	","
47*7c478bd9Sstevel@tonic-gate #define	OPEN_PAREN_CHAR		'('
48*7c478bd9Sstevel@tonic-gate #define	CLOSE_PAREN_CHAR	')'
49*7c478bd9Sstevel@tonic-gate #define	DOUBLE_QUOTE_CHAR	'"'
50*7c478bd9Sstevel@tonic-gate #define	PERIOD_CHAR		'.'
51*7c478bd9Sstevel@tonic-gate #define	COLON_CHAR		':'
52*7c478bd9Sstevel@tonic-gate #define	POUND_SIGN		'#'
53*7c478bd9Sstevel@tonic-gate #define	SEMI_COLON_CHAR		';'
54*7c478bd9Sstevel@tonic-gate #define	QUESTION_MARK		'?'
55*7c478bd9Sstevel@tonic-gate #define	PLUS_SIGN		'+'
56*7c478bd9Sstevel@tonic-gate #define	PERCENT_SIGN		'%'
57*7c478bd9Sstevel@tonic-gate #define	OPEN_BRACKET		'['
58*7c478bd9Sstevel@tonic-gate #define	CLOSE_BRACKET		']'
59*7c478bd9Sstevel@tonic-gate #define	ASTERIX_CHAR		'*'
60*7c478bd9Sstevel@tonic-gate #define	DASH_CHAR				'-'
61*7c478bd9Sstevel@tonic-gate #define	SINGLE_QUOTE_CHAR		'\''
62*7c478bd9Sstevel@tonic-gate #define	DEFAULT_COMMENT_CHAR	'#'
63*7c478bd9Sstevel@tonic-gate #define	DEFAULT_SEP_STRING		" 	"
64*7c478bd9Sstevel@tonic-gate #define	SPACE_CHAR				' '
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #define	FOREVER				-1
67*7c478bd9Sstevel@tonic-gate #define	FIFTEEN_SECONDS			15
68*7c478bd9Sstevel@tonic-gate #define	TWO_MINUTES			120
69*7c478bd9Sstevel@tonic-gate #define	THIRTY_MINUTES			1800
70*7c478bd9Sstevel@tonic-gate #define	THREE_MINUTES			180
71*7c478bd9Sstevel@tonic-gate #define	ONE_HOUR			3600
72*7c478bd9Sstevel@tonic-gate #define	MAX_LDAP_CONFIG_RETRY_TIME	60
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate #define	NO_VALUE_SET			-2
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #define	INITIAL_UPDATE_NO_ACTION	-3
77*7c478bd9Sstevel@tonic-gate #define	NO_INITIAL_UPDATE_NO_ACTION	-4
78*7c478bd9Sstevel@tonic-gate #define	FROM_NO_INITIAL_UPDATE		-5
79*7c478bd9Sstevel@tonic-gate #define	TO_NO_INITIAL_UPDATE		-6
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate #define	BUFSIZE				8192
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #ifndef UINT32_MAX
84*7c478bd9Sstevel@tonic-gate #define	UINT32_MAX		(4294967295U)
85*7c478bd9Sstevel@tonic-gate #endif
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	IS_TERMINAL_CHAR(c)			\
88*7c478bd9Sstevel@tonic-gate 		((c) == QUESTION_MARK	||	\
89*7c478bd9Sstevel@tonic-gate 		(c) == EQUAL_CHAR 	||	\
90*7c478bd9Sstevel@tonic-gate 		(c) == COMMA_CHAR	||	\
91*7c478bd9Sstevel@tonic-gate 		(c) == CLOSE_PAREN_CHAR ||	\
92*7c478bd9Sstevel@tonic-gate 		(c) == COLON_CHAR	||	\
93*7c478bd9Sstevel@tonic-gate 		(c) == SEMI_COLON_CHAR)
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate #define	TIME_MAX LONG_MAX
96*7c478bd9Sstevel@tonic-gate #define	WILL_OVERFLOW_TIME(t, d) ((t) > TIME_MAX/10 ||	\
97*7c478bd9Sstevel@tonic-gate 	((t) == TIME_MAX/10 && d > TIME_MAX % 10))
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #define	LIMIT_MAX	(65535)
100*7c478bd9Sstevel@tonic-gate #define	WILL_OVERFLOW_LIMIT(t, d) ((t) > LIMIT_MAX/10 ||	\
101*7c478bd9Sstevel@tonic-gate 	((t) == LIMIT_MAX/10 && d > LIMIT_MAX % 10))
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #define	WILL_OVERFLOW_INT(t, d) ((t) > INT_MAX/10 ||	\
104*7c478bd9Sstevel@tonic-gate 	((t) == INT_MAX/10 && d > INT_MAX % 10))
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /* initial configuration keywords */
107*7c478bd9Sstevel@tonic-gate /* for NIS+ */
108*7c478bd9Sstevel@tonic-gate #define	CONFIG_DN		"nisplusLDAPconfigDN"
109*7c478bd9Sstevel@tonic-gate #define	CONFIG_SERVER_LIST	"nisplusLDAPconfigPreferredServerList"
110*7c478bd9Sstevel@tonic-gate #define	CONFIG_AUTH_METHOD	"nisplusLDAPconfigAuthenticationMethod"
111*7c478bd9Sstevel@tonic-gate #define	CONFIG_TLS_OPTION	"nisplusLDAPconfigTLS"
112*7c478bd9Sstevel@tonic-gate #define	CONFIG_TLS_CERT_DB	"nisplusLDAPconfigTLSCertificateDBPath"
113*7c478bd9Sstevel@tonic-gate #define	CONFIG_PROXY_USER	"nisplusLDAPconfigProxyUser"
114*7c478bd9Sstevel@tonic-gate #define	CONFIG_PROXY_PASSWD	"nisplusLDAPconfigProxyPassword"
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #define	IS_CONFIG_KEYWORD(x)	\
117*7c478bd9Sstevel@tonic-gate 	((x) >= key_config_dn && (x) <= key_config_proxy_passwd)
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /* LDAP server keywords */
120*7c478bd9Sstevel@tonic-gate /* for NIS+ */
121*7c478bd9Sstevel@tonic-gate #define	PREFERRED_SERVERS	"preferredServerList"
122*7c478bd9Sstevel@tonic-gate #define	AUTH_METHOD		"authenticationMethod"
123*7c478bd9Sstevel@tonic-gate #define	TLS_OPTION		"nisplusLDAPTLS"
124*7c478bd9Sstevel@tonic-gate #define	TLS_CERT_DB		"nisplusLDAPTLSCertificateDBPath"
125*7c478bd9Sstevel@tonic-gate #define	SEARCH_BASE		"defaultSearchBase"
126*7c478bd9Sstevel@tonic-gate #define	PROXY_USER		"nisplusLDAPproxyUser"
127*7c478bd9Sstevel@tonic-gate #define	PROXY_PASSWD		"nisplusLDAPproxyPassword"
128*7c478bd9Sstevel@tonic-gate #define	LDAP_BASE_DOMAIN	"nisplusLDAPbaseDomain"
129*7c478bd9Sstevel@tonic-gate #define	BIND_TIMEOUT		"nisplusLDAPbindTimeout"
130*7c478bd9Sstevel@tonic-gate #define	SEARCH_TIMEOUT		"nisplusLDAPsearchTimeout"
131*7c478bd9Sstevel@tonic-gate #define	MODIFY_TIMEOUT		"nisplusLDAPmodifyTimeout"
132*7c478bd9Sstevel@tonic-gate #define	ADD_TIMEOUT		"nisplusLDAPaddTimeout"
133*7c478bd9Sstevel@tonic-gate #define	DELETE_TIMEOUT		"nisplusLDAPdeleteTimeout"
134*7c478bd9Sstevel@tonic-gate #define	SEARCH_TIME_LIMIT	"nisplusLDAPsearchTimeLimit"
135*7c478bd9Sstevel@tonic-gate #define	SEARCH_SIZE_LIMIT	"nisplusLDAPsearchSizeLimit"
136*7c478bd9Sstevel@tonic-gate #define	FOLLOW_REFERRAL		"nisplusLDAPfollowReferral"
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate #define	IS_BIND_INFO(x)	\
139*7c478bd9Sstevel@tonic-gate 	((x) >= key_preferred_servers && (x) <= key_follow_referral)
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /* This information will be need to determine the server behavior */
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate /* for NIS+ */
144*7c478bd9Sstevel@tonic-gate #define	INITIAL_UPDATE_ACTION	"nisplusLDAPinitialUpdateAction"
145*7c478bd9Sstevel@tonic-gate #define	INITIAL_UPDATE_ONLY	"nisplusLDAPinitialUpdateOnly"
146*7c478bd9Sstevel@tonic-gate #define	RETRIEVE_ERROR_ACTION	"nisplusLDAPretrieveErrorAction"
147*7c478bd9Sstevel@tonic-gate #define	RETREIVE_ERROR_ATTEMPTS	"nisplusLDAPretrieveErrorAttempts"
148*7c478bd9Sstevel@tonic-gate #define	RETREIVE_ERROR_TIMEOUT	"nisplusLDAPretrieveErrorTimeout"
149*7c478bd9Sstevel@tonic-gate #define	STORE_ERROR_ACTION	"nisplusLDAPstoreErrorAction"
150*7c478bd9Sstevel@tonic-gate #define	STORE_ERROR_ATTEMPTS	"nisplusLDAPstoreErrorAttempts"
151*7c478bd9Sstevel@tonic-gate #define	STORE_ERROR_TIMEOUT	"nisplusLDAPstoreErrorTimeout"
152*7c478bd9Sstevel@tonic-gate #define	REFRESH_ERROR_ACTION	"nisplusLDAPrefreshErrorAction"
153*7c478bd9Sstevel@tonic-gate #define	REFRESH_ERROR_ATTEMPTS	"nisplusLDAPrefreshErrorAttempts"
154*7c478bd9Sstevel@tonic-gate #define	REFRESH_ERROR_TIMEOUT	"nisplusLDAPrefreshErrorTimeout"
155*7c478bd9Sstevel@tonic-gate #define	THREAD_CREATE_ERROR_ACTION	\
156*7c478bd9Sstevel@tonic-gate 				"nisplusThreadCreationErrorAction"
157*7c478bd9Sstevel@tonic-gate #define	THREAD_CREATE_ERROR_ATTEMPTS	\
158*7c478bd9Sstevel@tonic-gate 				"nisplusThreadCreationErrorAttempts"
159*7c478bd9Sstevel@tonic-gate #define	THREAD_CREATE_ERROR_TIMEOUT	\
160*7c478bd9Sstevel@tonic-gate 				"nisplusThreadCreationErrorTimeout"
161*7c478bd9Sstevel@tonic-gate #define	DUMP_ERROR_ACTION	"nisplusDumpErrorAction"
162*7c478bd9Sstevel@tonic-gate #define	DUMP_ERROR_ATTEMPTS	"nisplusDumpErrorAttempts"
163*7c478bd9Sstevel@tonic-gate #define	DUMP_ERROR_TIMEOUT	"nisplusDumpErrorTimeout"
164*7c478bd9Sstevel@tonic-gate #define	RESYNC			"nisplusResyncService"
165*7c478bd9Sstevel@tonic-gate #define	UPDATE_BATCHING		"nisplusUpdateBatching"
166*7c478bd9Sstevel@tonic-gate #define	UPDATE_BATCHING_TIMEOUT	"nisplusUpdateBatchingTimeout"
167*7c478bd9Sstevel@tonic-gate #define	MATCH_FETCH		"nisplusLDAPmatchFetchAction"
168*7c478bd9Sstevel@tonic-gate #define	NUMBER_THEADS		"nisplusNumberOfServiceThreads"
169*7c478bd9Sstevel@tonic-gate #define	YP_EMULATION		"ENABLE_NIS_YP_EMULATION"
170*7c478bd9Sstevel@tonic-gate #define	MAX_RPC_RECSIZE		"nisplusMaxRPCRecordSize"
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate #define	IS_OPER_INFO(x)		\
173*7c478bd9Sstevel@tonic-gate 	((x) >= key_initial_update_action && (x) <= key_max_rpc_recsize)
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate #define	DB_ID_MAP		"nisplusLDAPdatabaseIdMapping"
176*7c478bd9Sstevel@tonic-gate #define	ENTRY_TTL		"nisplusLDAPentryTtl"
177*7c478bd9Sstevel@tonic-gate #define	LDAP_OBJECT_DN	"nisplusLDAPobjectDN"
178*7c478bd9Sstevel@tonic-gate #define	LDAP_TO_NISPLUS_MAP	"nisplusLDAPcolumnFromAttribute"
179*7c478bd9Sstevel@tonic-gate #define	NISPLUS_TO_LDAP_MAP	"nisplusLDAPattributeFromColumn"
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate /* The following definitions are for NIS */
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_DN			"nisLDAPconfigDN"
184*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_SERVER_LIST	"nisLDAPconfigPreferredServerList"
185*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_AUTH_METHOD	"nisLDAPconfigAuthenticationMethod"
186*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_TLS_OPTION	"nisLDAPconfigTLS"
187*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_TLS_CERT_DB	"nisLDAPconfigTLSCertificateDBPath"
188*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_PROXY_USER	"nisLDAPconfigProxyUser"
189*7c478bd9Sstevel@tonic-gate #define	YP_CONFIG_PROXY_PASSWD	"nisLDAPconfigProxyPassword"
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate #define	IS_YP_CONFIG_KEYWORD(x) \
192*7c478bd9Sstevel@tonic-gate 	((x) >= key_yp_config_dn && (x) <= key_yp_config_proxy_passwd)
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate #define	YP_TLS_OPTION		"nisLDAPTLS"
195*7c478bd9Sstevel@tonic-gate #define	YP_TLS_CERT_DB		"nisLDAPTLSCertificateDBPath"
196*7c478bd9Sstevel@tonic-gate #define	YP_PROXY_USER		"nisLDAPproxyUser"
197*7c478bd9Sstevel@tonic-gate #define	YP_PROXY_PASSWD		"nisLDAPproxyPassword"
198*7c478bd9Sstevel@tonic-gate #define	YP_LDAP_BASE_DOMAIN		"nisLDAPbaseDomain"
199*7c478bd9Sstevel@tonic-gate #define	YP_BIND_TIMEOUT		"nisLDAPbindTimeout"
200*7c478bd9Sstevel@tonic-gate #define	YP_SEARCH_TIMEOUT	"nisLDAPsearchTimeout"
201*7c478bd9Sstevel@tonic-gate #define	YP_MODIFY_TIMEOUT	"nisLDAPmodifyTimeout"
202*7c478bd9Sstevel@tonic-gate #define	YP_ADD_TIMEOUT		"nisLDAPaddTimeout"
203*7c478bd9Sstevel@tonic-gate #define	YP_DELETE_TIMEOUT	"nisLDAPdeleteTimeout"
204*7c478bd9Sstevel@tonic-gate #define	YP_SEARCH_TIME_LIMIT	"nisLDAPsearchTimeLimit"
205*7c478bd9Sstevel@tonic-gate #define	YP_SEARCH_SIZE_LIMIT	"nisLDAPsearchSizeLimit"
206*7c478bd9Sstevel@tonic-gate #define	YP_FOLLOW_REFERRAL		"nisLDAPfollowReferral"
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate #define	IS_YP_BIND_INFO(x)  \
209*7c478bd9Sstevel@tonic-gate 	((x) == key_preferred_servers || \
210*7c478bd9Sstevel@tonic-gate 	(x) == key_auth_method || \
211*7c478bd9Sstevel@tonic-gate 	(x) == key_search_base || \
212*7c478bd9Sstevel@tonic-gate 	((x) >= key_yp_tls_option && (x) <= key_yp_follow_referral))
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #define	YP_RETRIEVE_ERROR_ACTION	"nisLDAPretrieveErrorAction"
215*7c478bd9Sstevel@tonic-gate #define	YP_RETREIVE_ERROR_ATTEMPTS	"nisLDAPretrieveErrorAttempts"
216*7c478bd9Sstevel@tonic-gate #define	YP_RETREIVE_ERROR_TIMEOUT	"nisLDAPretrieveErrorTimeout"
217*7c478bd9Sstevel@tonic-gate #define	YP_STORE_ERROR_ACTION		"nisLDAPstoreErrorAction"
218*7c478bd9Sstevel@tonic-gate #define	YP_STORE_ERROR_ATTEMPTS		"nisLDAPstoreErrorAttempts"
219*7c478bd9Sstevel@tonic-gate #define	YP_STORE_ERROR_TIMEOUT		"nisLDAPstoreErrorTimeout"
220*7c478bd9Sstevel@tonic-gate #define	YP_MATCH_FETCH			"nisLDAPmatchFetchAction"
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate #define	IS_YP_OPER_INFO(x)  \
223*7c478bd9Sstevel@tonic-gate 	((x) >= key_yp_retrieve_error_action && (x) <= key_yp_match_fetch)
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate #define	YP_DOMAIN_CONTEXT	"nisLDAPdomainContext"
226*7c478bd9Sstevel@tonic-gate #define	YPPASSWDD_DOMAINS	"nisLDAPyppasswddDomains"
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate #define	IS_YP_DOMAIN_INFO(x)	\
229*7c478bd9Sstevel@tonic-gate 	((x) >= key_yp_domain_context && (x) <= key_yppasswdd_domains)
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate #define	YP_DB_ID_MAP		"nisLDAPdatabaseIdMapping"
232*7c478bd9Sstevel@tonic-gate #define	YP_COMMENT_CHAR		"nisLDAPcommentChar"
233*7c478bd9Sstevel@tonic-gate #define	YP_MAP_FLAGS		"nisLDAPmapFlags"
234*7c478bd9Sstevel@tonic-gate #define	YP_ENTRY_TTL		"nisLDAPentryTtl"
235*7c478bd9Sstevel@tonic-gate #define	YP_NAME_FIELDS		"nisLDAPnameFields"
236*7c478bd9Sstevel@tonic-gate #define	YP_SPLIT_FIELD		"nisLDAPsplitField"
237*7c478bd9Sstevel@tonic-gate #define	YP_REPEATED_FIELD_SEPARATORS	"nisLDAPrepeatedFieldSeparators"
238*7c478bd9Sstevel@tonic-gate #define	YP_LDAP_OBJECT_DN	"nisLDAPobjectDN"
239*7c478bd9Sstevel@tonic-gate #define	LDAP_TO_NIS_MAP		"nisLDAPfieldFromAttribute"
240*7c478bd9Sstevel@tonic-gate #define	NIS_TO_LDAP_MAP		"nisLDAPattributeFromField"
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate #define	IS_YP_MAP_ATTR(x)	\
243*7c478bd9Sstevel@tonic-gate 	((x) == key_yp_domain_context || \
244*7c478bd9Sstevel@tonic-gate 	(x) == key_yppasswdd_domains || \
245*7c478bd9Sstevel@tonic-gate 	((x) >= key_yp_db_id_map && (x) <= key_nis_to_ldap_map))
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate #define	DEFAULT_YP_SEARCH_TIMEOUT	THREE_MINUTES
248*7c478bd9Sstevel@tonic-gate #define	DEFAULT_BIND_TIMEOUT		FIFTEEN_SECONDS
249*7c478bd9Sstevel@tonic-gate #define	DEFAULT_SEARCH_TIMEOUT		FIFTEEN_SECONDS
250*7c478bd9Sstevel@tonic-gate #define	DEFAULT_MODIFY_TIMEOUT		FIFTEEN_SECONDS
251*7c478bd9Sstevel@tonic-gate #define	DEFAULT_ADD_TIMEOUT		FIFTEEN_SECONDS
252*7c478bd9Sstevel@tonic-gate #define	DEFAULT_DELETE_TIMEOUT		FIFTEEN_SECONDS
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate #define	DEFAULT_SEARCH_TIME_LIMIT	LDAP_NO_LIMIT
255*7c478bd9Sstevel@tonic-gate #define	DEFAULT_SEARCH_SIZE_LIMIT	LDAP_NO_LIMIT
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate #define	DEFAULT_THREAD_ERROR_ATTEMPTS	FOREVER
258*7c478bd9Sstevel@tonic-gate #define	DEFAULT_THREAD_ERROR_TIME_OUT	FIFTEEN_SECONDS
259*7c478bd9Sstevel@tonic-gate #define	DEFAULT_DUMP_ERROR_ATTEMPTS	FOREVER
260*7c478bd9Sstevel@tonic-gate #define	DEFAULT_DUMP_ERROR_TIME_OUT	FIFTEEN_SECONDS
261*7c478bd9Sstevel@tonic-gate #define	DEFAULT_RETRIEVE_ERROR_ATTEMPTS	FOREVER
262*7c478bd9Sstevel@tonic-gate #define	DEFAULT_RETRIEVE_ERROR_TIME_OUT	FIFTEEN_SECONDS
263*7c478bd9Sstevel@tonic-gate #define	DEFAULT_STORE_ERROR_ATTEMPTS	FOREVER
264*7c478bd9Sstevel@tonic-gate #define	DEFAULT_STORE_ERROR_TIME_OUT	FIFTEEN_SECONDS
265*7c478bd9Sstevel@tonic-gate #define	DEFAULT_REFRESH_ERROR_ATTEMPTS	FOREVER
266*7c478bd9Sstevel@tonic-gate #define	DEFAULT_REFRESH_ERROR_TIME_OUT	FIFTEEN_SECONDS
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate #define	DEFAULT_BATCHING_TIME_OUT	TWO_MINUTES
269*7c478bd9Sstevel@tonic-gate #define	DEFAULT_NUMBER_OF_THREADS	0
270*7c478bd9Sstevel@tonic-gate #define	DEFAULT_YP_EMULATION		0
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate #define	DEFAULT_TTL_HIGH		(ONE_HOUR + THIRTY_MINUTES)
273*7c478bd9Sstevel@tonic-gate #define	DEFAULT_TTL_LOW			(ONE_HOUR - THIRTY_MINUTES)
274*7c478bd9Sstevel@tonic-gate #define	DEFAULT_TTL			ONE_HOUR
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate typedef enum {
277*7c478bd9Sstevel@tonic-gate 	no_parse_error,
278*7c478bd9Sstevel@tonic-gate 	parse_no_mem_error,
279*7c478bd9Sstevel@tonic-gate 	parse_bad_key,
280*7c478bd9Sstevel@tonic-gate 	parse_bad_continuation_error,
281*7c478bd9Sstevel@tonic-gate 	parse_line_too_long,
282*7c478bd9Sstevel@tonic-gate 	parse_internal_error,
283*7c478bd9Sstevel@tonic-gate 	parse_initial_update_action_error,
284*7c478bd9Sstevel@tonic-gate 	parse_initial_update_only_error,
285*7c478bd9Sstevel@tonic-gate 	parse_retrieve_error_action_error,
286*7c478bd9Sstevel@tonic-gate 	parse_store_error_action_error,
287*7c478bd9Sstevel@tonic-gate 	parse_refresh_error_action_error,
288*7c478bd9Sstevel@tonic-gate 	parse_thread_create_error_action_error,
289*7c478bd9Sstevel@tonic-gate 	parse_dump_error_action_error,
290*7c478bd9Sstevel@tonic-gate 	parse_resync_error,
291*7c478bd9Sstevel@tonic-gate 	parse_update_batching_error,
292*7c478bd9Sstevel@tonic-gate 	parse_match_fetch_error,
293*7c478bd9Sstevel@tonic-gate 	parse_no_object_dn,
294*7c478bd9Sstevel@tonic-gate 	parse_invalid_scope,
295*7c478bd9Sstevel@tonic-gate 	parse_invalid_ldap_search_filter,
296*7c478bd9Sstevel@tonic-gate 	parse_semi_expected_error,
297*7c478bd9Sstevel@tonic-gate 	parse_mismatched_brackets,
298*7c478bd9Sstevel@tonic-gate 	parse_unsupported_format,
299*7c478bd9Sstevel@tonic-gate 	parse_unexpected_dash,
300*7c478bd9Sstevel@tonic-gate 	parse_unmatched_escape,
301*7c478bd9Sstevel@tonic-gate 	parse_bad_lhs_format_error,
302*7c478bd9Sstevel@tonic-gate 	parse_comma_expected_error,
303*7c478bd9Sstevel@tonic-gate 	parse_equal_expected_error,
304*7c478bd9Sstevel@tonic-gate 	parse_close_paren_expected_error,
305*7c478bd9Sstevel@tonic-gate 	parse_too_many_extract_items,
306*7c478bd9Sstevel@tonic-gate 	parse_not_enough_extract_items,
307*7c478bd9Sstevel@tonic-gate 	parse_bad_print_format,
308*7c478bd9Sstevel@tonic-gate 	parse_bad_elide_char,
309*7c478bd9Sstevel@tonic-gate 	parse_start_rhs_unrecognized,
310*7c478bd9Sstevel@tonic-gate 	parse_item_expected_error,
311*7c478bd9Sstevel@tonic-gate 	parse_format_string_expected_error,
312*7c478bd9Sstevel@tonic-gate 	parse_unexpected_data_end_rule,
313*7c478bd9Sstevel@tonic-gate 	parse_bad_ttl_format_error,
314*7c478bd9Sstevel@tonic-gate 	parse_bad_auth_method_error,
315*7c478bd9Sstevel@tonic-gate 	parse_open_file_error,
316*7c478bd9Sstevel@tonic-gate 	parse_no_proxy_dn_error,
317*7c478bd9Sstevel@tonic-gate 	parse_no_config_auth_error,
318*7c478bd9Sstevel@tonic-gate 	parse_no_proxy_auth_error,
319*7c478bd9Sstevel@tonic-gate 	parse_ldap_init_error,
320*7c478bd9Sstevel@tonic-gate 	parse_ldap_bind_error,
321*7c478bd9Sstevel@tonic-gate 	parse_ldap_search_error,
322*7c478bd9Sstevel@tonic-gate 	parse_ldap_get_values_error,
323*7c478bd9Sstevel@tonic-gate 	parse_object_dn_syntax_error,
324*7c478bd9Sstevel@tonic-gate 	parse_invalid_dn,
325*7c478bd9Sstevel@tonic-gate 	parse_bad_index_format,
326*7c478bd9Sstevel@tonic-gate 	parse_bad_item_format,
327*7c478bd9Sstevel@tonic-gate 	parse_bad_ldap_item_format,
328*7c478bd9Sstevel@tonic-gate 	parse_invalid_print_arg,
329*7c478bd9Sstevel@tonic-gate 	parse_bad_extract_format_spec,
330*7c478bd9Sstevel@tonic-gate 	parse_no_db_del_mapping_rule,
331*7c478bd9Sstevel@tonic-gate 	parse_invalid_db_del_mapping_rule,
332*7c478bd9Sstevel@tonic-gate 	parse_bad_domain_name,
333*7c478bd9Sstevel@tonic-gate 	parse_bad_dn,
334*7c478bd9Sstevel@tonic-gate 	parse_yes_or_no_expected_error,
335*7c478bd9Sstevel@tonic-gate 	parse_bad_uint_error,
336*7c478bd9Sstevel@tonic-gate 	parse_bad_int_error,
337*7c478bd9Sstevel@tonic-gate 	parse_bad_command_line_attribute_format,
338*7c478bd9Sstevel@tonic-gate 	parse_no_ldap_server_error,
339*7c478bd9Sstevel@tonic-gate 	parse_bad_ber_format,
340*7c478bd9Sstevel@tonic-gate 	parse_no_config_server_addr,
341*7c478bd9Sstevel@tonic-gate 	parse_bad_time_error,
342*7c478bd9Sstevel@tonic-gate 	parse_lhs_rhs_type_mismatch,
343*7c478bd9Sstevel@tonic-gate 	parse_no_match_item,
344*7c478bd9Sstevel@tonic-gate 	parse_cannot_elide,
345*7c478bd9Sstevel@tonic-gate 	parse_bad_tls_option_error,
346*7c478bd9Sstevel@tonic-gate 	parse_ldapssl_client_init_error,
347*7c478bd9Sstevel@tonic-gate 	parse_ldapssl_init_error,
348*7c478bd9Sstevel@tonic-gate 	parse_no_available_referrals_error,
349*7c478bd9Sstevel@tonic-gate 	parse_no_config_cert_db,
350*7c478bd9Sstevel@tonic-gate 	parse_no_cert_db,
351*7c478bd9Sstevel@tonic-gate 	parse_unknown_yp_domain_error,
352*7c478bd9Sstevel@tonic-gate 	parse_unexpected_yp_domain_end_error,
353*7c478bd9Sstevel@tonic-gate 	parse_bad_map_error,
354*7c478bd9Sstevel@tonic-gate 	parse_bad_yp_comment_error,
355*7c478bd9Sstevel@tonic-gate 	parse_bad_field_separator_error,
356*7c478bd9Sstevel@tonic-gate 	parse_bad_name_field,
357*7c478bd9Sstevel@tonic-gate 	parse_yp_retrieve_error_action_error,
358*7c478bd9Sstevel@tonic-gate 	parse_yp_store_error_action_error
359*7c478bd9Sstevel@tonic-gate } parse_error;
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate typedef enum {
362*7c478bd9Sstevel@tonic-gate 	no_conn_error,
363*7c478bd9Sstevel@tonic-gate 	conn_no_mem_error,
364*7c478bd9Sstevel@tonic-gate 	conn_ldap_init_error,
365*7c478bd9Sstevel@tonic-gate 	conn_unsupported_ldap_bind_method,
366*7c478bd9Sstevel@tonic-gate 	conn_ldap_bind_error
367*7c478bd9Sstevel@tonic-gate } conn_error;
368*7c478bd9Sstevel@tonic-gate 
369*7c478bd9Sstevel@tonic-gate typedef enum {
370*7c478bd9Sstevel@tonic-gate 	key_bad = -1,
371*7c478bd9Sstevel@tonic-gate 	no_more_keys = 0,
372*7c478bd9Sstevel@tonic-gate 	key_config_dn = 1,
373*7c478bd9Sstevel@tonic-gate 	key_config_server_list,
374*7c478bd9Sstevel@tonic-gate 	key_config_auth_method,
375*7c478bd9Sstevel@tonic-gate 	key_config_tls_option,
376*7c478bd9Sstevel@tonic-gate 	key_config_tls_certificate_db,
377*7c478bd9Sstevel@tonic-gate 	key_config_proxy_user,
378*7c478bd9Sstevel@tonic-gate 	key_config_proxy_passwd,
379*7c478bd9Sstevel@tonic-gate 	key_preferred_servers,
380*7c478bd9Sstevel@tonic-gate 	key_auth_method,
381*7c478bd9Sstevel@tonic-gate 	key_tls_option,
382*7c478bd9Sstevel@tonic-gate 	key_tls_certificate_db,
383*7c478bd9Sstevel@tonic-gate 	key_search_base,
384*7c478bd9Sstevel@tonic-gate 	key_proxy_user,
385*7c478bd9Sstevel@tonic-gate 	key_proxy_passwd,
386*7c478bd9Sstevel@tonic-gate 	key_ldap_base_domain,
387*7c478bd9Sstevel@tonic-gate 	key_bind_timeout,
388*7c478bd9Sstevel@tonic-gate 	key_search_timeout,
389*7c478bd9Sstevel@tonic-gate 	key_modify_timeout,
390*7c478bd9Sstevel@tonic-gate 	key_add_timeout,
391*7c478bd9Sstevel@tonic-gate 	key_delete_timeout,
392*7c478bd9Sstevel@tonic-gate 	key_search_time_limit,
393*7c478bd9Sstevel@tonic-gate 	key_search_size_limit,
394*7c478bd9Sstevel@tonic-gate 	key_follow_referral,
395*7c478bd9Sstevel@tonic-gate 	key_initial_update_action,
396*7c478bd9Sstevel@tonic-gate 	key_initial_update_only,
397*7c478bd9Sstevel@tonic-gate 	key_retrieve_error_action,
398*7c478bd9Sstevel@tonic-gate 	key_retrieve_error_attempts,
399*7c478bd9Sstevel@tonic-gate 	key_retreive_error_timeout,
400*7c478bd9Sstevel@tonic-gate 	key_store_error_action,
401*7c478bd9Sstevel@tonic-gate 	key_store_error_attempts,
402*7c478bd9Sstevel@tonic-gate 	key_store_error_timeout,
403*7c478bd9Sstevel@tonic-gate 	key_refresh_error_action,
404*7c478bd9Sstevel@tonic-gate 	key_refresh_error_attempts,
405*7c478bd9Sstevel@tonic-gate 	key_refresh_error_timeout,
406*7c478bd9Sstevel@tonic-gate 	key_thread_create_error_action,
407*7c478bd9Sstevel@tonic-gate 	key_thread_create_error_attempts,
408*7c478bd9Sstevel@tonic-gate 	key_thread_create_error_timeout,
409*7c478bd9Sstevel@tonic-gate 	key_dump_error_action,
410*7c478bd9Sstevel@tonic-gate 	key_dump_error_attempts,
411*7c478bd9Sstevel@tonic-gate 	key_dump_error_timeout,
412*7c478bd9Sstevel@tonic-gate 	key_resync,
413*7c478bd9Sstevel@tonic-gate 	key_update_batching,
414*7c478bd9Sstevel@tonic-gate 	key_update_batching_timeout,
415*7c478bd9Sstevel@tonic-gate 	key_match_fetch,
416*7c478bd9Sstevel@tonic-gate 	key_number_threads,
417*7c478bd9Sstevel@tonic-gate 	key_yp_emulation,
418*7c478bd9Sstevel@tonic-gate 	key_max_rpc_recsize,
419*7c478bd9Sstevel@tonic-gate 	key_db_id_map,
420*7c478bd9Sstevel@tonic-gate 	key_entry_ttl,
421*7c478bd9Sstevel@tonic-gate 	key_ldap_object_dn,
422*7c478bd9Sstevel@tonic-gate 	key_ldap_to_nisplus_map,
423*7c478bd9Sstevel@tonic-gate 	key_nisplus_to_ldap_map,
424*7c478bd9Sstevel@tonic-gate 	key_yp_config_dn,
425*7c478bd9Sstevel@tonic-gate 	key_yp_config_server_list,
426*7c478bd9Sstevel@tonic-gate 	key_yp_config_auth_method,
427*7c478bd9Sstevel@tonic-gate 	key_yp_config_tls_option,
428*7c478bd9Sstevel@tonic-gate 	key_yp_config_tls_certificate_db,
429*7c478bd9Sstevel@tonic-gate 	key_yp_config_proxy_user,
430*7c478bd9Sstevel@tonic-gate 	key_yp_config_proxy_passwd,
431*7c478bd9Sstevel@tonic-gate 	key_yp_preferred_servers,
432*7c478bd9Sstevel@tonic-gate 	key_yp_auth_method,
433*7c478bd9Sstevel@tonic-gate 	key_yp_tls_option,
434*7c478bd9Sstevel@tonic-gate 	key_yp_tls_certificate_db,
435*7c478bd9Sstevel@tonic-gate 	key_yp_search_base,
436*7c478bd9Sstevel@tonic-gate 	key_yp_proxy_user,
437*7c478bd9Sstevel@tonic-gate 	key_yp_proxy_passwd,
438*7c478bd9Sstevel@tonic-gate 	key_yp_ldap_base_domain,
439*7c478bd9Sstevel@tonic-gate 	key_yp_bind_timeout,
440*7c478bd9Sstevel@tonic-gate 	key_yp_search_timeout,
441*7c478bd9Sstevel@tonic-gate 	key_yp_modify_timeout,
442*7c478bd9Sstevel@tonic-gate 	key_yp_add_timeout,
443*7c478bd9Sstevel@tonic-gate 	key_yp_delete_timeout,
444*7c478bd9Sstevel@tonic-gate 	key_yp_search_time_limit,
445*7c478bd9Sstevel@tonic-gate 	key_yp_search_size_limit,
446*7c478bd9Sstevel@tonic-gate 	key_yp_follow_referral,
447*7c478bd9Sstevel@tonic-gate 	key_yp_retrieve_error_action,
448*7c478bd9Sstevel@tonic-gate 	key_yp_retrieve_error_attempts,
449*7c478bd9Sstevel@tonic-gate 	key_yp_retreive_error_timeout,
450*7c478bd9Sstevel@tonic-gate 	key_yp_store_error_action,
451*7c478bd9Sstevel@tonic-gate 	key_yp_store_error_attempts,
452*7c478bd9Sstevel@tonic-gate 	key_yp_store_error_timeout,
453*7c478bd9Sstevel@tonic-gate 	key_yp_match_fetch,
454*7c478bd9Sstevel@tonic-gate 	key_yp_domain_context,
455*7c478bd9Sstevel@tonic-gate 	key_yppasswdd_domains,
456*7c478bd9Sstevel@tonic-gate 	key_yp_db_id_map,
457*7c478bd9Sstevel@tonic-gate 	key_yp_comment_char,
458*7c478bd9Sstevel@tonic-gate 	key_yp_map_flags,
459*7c478bd9Sstevel@tonic-gate 	key_yp_entry_ttl,
460*7c478bd9Sstevel@tonic-gate 	key_yp_name_fields,
461*7c478bd9Sstevel@tonic-gate 	key_yp_split_field,
462*7c478bd9Sstevel@tonic-gate 	key_yp_repeated_field_separators,
463*7c478bd9Sstevel@tonic-gate 	key_yp_ldap_object_dn,
464*7c478bd9Sstevel@tonic-gate 	key_ldap_to_nis_map,
465*7c478bd9Sstevel@tonic-gate 	key_nis_to_ldap_map,
466*7c478bd9Sstevel@tonic-gate 	n_config_keys
467*7c478bd9Sstevel@tonic-gate } config_key;
468*7c478bd9Sstevel@tonic-gate 
469*7c478bd9Sstevel@tonic-gate typedef enum {
470*7c478bd9Sstevel@tonic-gate 	string_token,
471*7c478bd9Sstevel@tonic-gate 	quoted_string_token,
472*7c478bd9Sstevel@tonic-gate 	equal_token,
473*7c478bd9Sstevel@tonic-gate 	comma_token,
474*7c478bd9Sstevel@tonic-gate 	open_paren_token,
475*7c478bd9Sstevel@tonic-gate 	close_paren_token,
476*7c478bd9Sstevel@tonic-gate 	colon_token,
477*7c478bd9Sstevel@tonic-gate 	no_token
478*7c478bd9Sstevel@tonic-gate } token_type;
479*7c478bd9Sstevel@tonic-gate 
480*7c478bd9Sstevel@tonic-gate typedef enum {
481*7c478bd9Sstevel@tonic-gate 	dn_no_token,
482*7c478bd9Sstevel@tonic-gate 	dn_semi_token,
483*7c478bd9Sstevel@tonic-gate 	dn_ques_token,
484*7c478bd9Sstevel@tonic-gate 	dn_colon_token,
485*7c478bd9Sstevel@tonic-gate 	dn_base_token,
486*7c478bd9Sstevel@tonic-gate 	dn_one_token,
487*7c478bd9Sstevel@tonic-gate 	dn_sub_token,
488*7c478bd9Sstevel@tonic-gate 	dn_text_token
489*7c478bd9Sstevel@tonic-gate } object_dn_token;
490*7c478bd9Sstevel@tonic-gate 
491*7c478bd9Sstevel@tonic-gate typedef enum {
492*7c478bd9Sstevel@tonic-gate 	dn_begin_parse,
493*7c478bd9Sstevel@tonic-gate 	dn_got_read_dn,
494*7c478bd9Sstevel@tonic-gate 	dn_got_read_q_scope,
495*7c478bd9Sstevel@tonic-gate 	dn_got_read_scope,
496*7c478bd9Sstevel@tonic-gate 	dn_got_read_q_filter,
497*7c478bd9Sstevel@tonic-gate 	dn_got_read_filter,
498*7c478bd9Sstevel@tonic-gate 	dn_got_write_colon,
499*7c478bd9Sstevel@tonic-gate 	dn_got_write_dn,
500*7c478bd9Sstevel@tonic-gate 	dn_got_write_q_scope,
501*7c478bd9Sstevel@tonic-gate 	dn_got_write_scope,
502*7c478bd9Sstevel@tonic-gate 	dn_got_write_q_filter,
503*7c478bd9Sstevel@tonic-gate 	dn_got_write_filter,
504*7c478bd9Sstevel@tonic-gate 	dn_got_delete_colon,
505*7c478bd9Sstevel@tonic-gate 	dn_got_delete_dsp
506*7c478bd9Sstevel@tonic-gate } parse_object_dn_state;
507*7c478bd9Sstevel@tonic-gate 
508*7c478bd9Sstevel@tonic-gate typedef enum {
509*7c478bd9Sstevel@tonic-gate 	none = 1,
510*7c478bd9Sstevel@tonic-gate 	simple,
511*7c478bd9Sstevel@tonic-gate 	cram_md5,
512*7c478bd9Sstevel@tonic-gate 	digest_md5
513*7c478bd9Sstevel@tonic-gate } auth_method_t;
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate typedef enum {
516*7c478bd9Sstevel@tonic-gate 	no_tls = 1,
517*7c478bd9Sstevel@tonic-gate 	ssl_tls
518*7c478bd9Sstevel@tonic-gate } tls_method_t;
519*7c478bd9Sstevel@tonic-gate 
520*7c478bd9Sstevel@tonic-gate typedef struct {
521*7c478bd9Sstevel@tonic-gate 	char		*config_dn;
522*7c478bd9Sstevel@tonic-gate 	char		*default_servers;
523*7c478bd9Sstevel@tonic-gate 	auth_method_t	auth_method;
524*7c478bd9Sstevel@tonic-gate 	tls_method_t	tls_method;
525*7c478bd9Sstevel@tonic-gate 	char		*proxy_dn;
526*7c478bd9Sstevel@tonic-gate 	char		*proxy_passwd;
527*7c478bd9Sstevel@tonic-gate 	char		*tls_cert_db;
528*7c478bd9Sstevel@tonic-gate } __nis_config_info_t;
529*7c478bd9Sstevel@tonic-gate 
530*7c478bd9Sstevel@tonic-gate typedef enum {
531*7c478bd9Sstevel@tonic-gate 	follow = 1,
532*7c478bd9Sstevel@tonic-gate 	no_follow
533*7c478bd9Sstevel@tonic-gate } follow_referral_t;
534*7c478bd9Sstevel@tonic-gate 
535*7c478bd9Sstevel@tonic-gate typedef struct {
536*7c478bd9Sstevel@tonic-gate 	char			*default_servers;
537*7c478bd9Sstevel@tonic-gate 	auth_method_t		auth_method;
538*7c478bd9Sstevel@tonic-gate 	tls_method_t		tls_method;
539*7c478bd9Sstevel@tonic-gate 	char			*default_search_base;
540*7c478bd9Sstevel@tonic-gate 	char			*proxy_dn;
541*7c478bd9Sstevel@tonic-gate 	char			*proxy_passwd;
542*7c478bd9Sstevel@tonic-gate 	char			*tls_cert_db;
543*7c478bd9Sstevel@tonic-gate 	char			*default_nis_domain;
544*7c478bd9Sstevel@tonic-gate 	struct timeval		bind_timeout;
545*7c478bd9Sstevel@tonic-gate 	struct timeval		search_timeout;
546*7c478bd9Sstevel@tonic-gate 	struct timeval		modify_timeout;
547*7c478bd9Sstevel@tonic-gate 	struct timeval		add_timeout;
548*7c478bd9Sstevel@tonic-gate 	struct timeval		delete_timeout;
549*7c478bd9Sstevel@tonic-gate 	int			search_time_limit;
550*7c478bd9Sstevel@tonic-gate 	int			search_size_limit;
551*7c478bd9Sstevel@tonic-gate 	follow_referral_t	follow_referral;
552*7c478bd9Sstevel@tonic-gate } __nis_ldap_proxy_info;
553*7c478bd9Sstevel@tonic-gate 
554*7c478bd9Sstevel@tonic-gate extern __nisdb_table_mapping_t	ldapDBTableMapping;
555*7c478bd9Sstevel@tonic-gate extern __nis_ldap_proxy_info	proxyInfo;
556*7c478bd9Sstevel@tonic-gate extern __nis_table_mapping_t	*ldapTableMapping;
557*7c478bd9Sstevel@tonic-gate 
558*7c478bd9Sstevel@tonic-gate extern int parse_ldap_migration(const char *const *cmdline_options,
559*7c478bd9Sstevel@tonic-gate 	const char *config_file);
560*7c478bd9Sstevel@tonic-gate 
561*7c478bd9Sstevel@tonic-gate extern void get_ldap_connection(LDAP **ld, time_t retry_time);
562*7c478bd9Sstevel@tonic-gate extern void free_ldap_connection(LDAP *ld);
563*7c478bd9Sstevel@tonic-gate extern void return_ldap_connection(LDAP *ld);
564*7c478bd9Sstevel@tonic-gate extern void free_ldap_connections();
565*7c478bd9Sstevel@tonic-gate 
566*7c478bd9Sstevel@tonic-gate 
567*7c478bd9Sstevel@tonic-gate extern void initialize_parse_structs(__nis_ldap_proxy_info *proxy_info,
568*7c478bd9Sstevel@tonic-gate     __nis_config_t *config_info, __nisdb_table_mapping_t *table_info);
569*7c478bd9Sstevel@tonic-gate extern void initialize_yp_parse_structs(__yp_domain_context_t *ypDomains);
570*7c478bd9Sstevel@tonic-gate 
571*7c478bd9Sstevel@tonic-gate /* Deallocation functions */
572*7c478bd9Sstevel@tonic-gate extern void free_parse_structs(void);
573*7c478bd9Sstevel@tonic-gate extern void free_yp_domain_context(__yp_domain_context_t *domains);
574*7c478bd9Sstevel@tonic-gate extern void free_config_info(__nis_config_info_t *config_info);
575*7c478bd9Sstevel@tonic-gate extern void free_mapping_rule(__nis_mapping_rule_t *rule);
576*7c478bd9Sstevel@tonic-gate extern void free_object_dn(__nis_object_dn_t *obj_dn);
577*7c478bd9Sstevel@tonic-gate extern void free_mapping_format(__nis_mapping_format_t *fmt);
578*7c478bd9Sstevel@tonic-gate extern void free_index(__nis_index_t *index);
579*7c478bd9Sstevel@tonic-gate extern void free_mapping_item(__nis_mapping_item_t *item);
580*7c478bd9Sstevel@tonic-gate extern void free_mapping_element(__nis_mapping_element_t *e);
581*7c478bd9Sstevel@tonic-gate extern void free_mapping_sub_element(__nis_mapping_sub_element_t *sub);
582*7c478bd9Sstevel@tonic-gate extern void free_proxy_info(__nis_ldap_proxy_info *proxy_info);
583*7c478bd9Sstevel@tonic-gate extern void free_table_mapping(__nis_table_mapping_t *mapping);
584*7c478bd9Sstevel@tonic-gate 
585*7c478bd9Sstevel@tonic-gate /* Parser functions */
586*7c478bd9Sstevel@tonic-gate extern int read_line(int fd, char *buffer, int buflen);
587*7c478bd9Sstevel@tonic-gate extern __nis_table_mapping_t *find_table_mapping(const char *s, int len,
588*7c478bd9Sstevel@tonic-gate     __nis_table_mapping_t *table_mapping);
589*7c478bd9Sstevel@tonic-gate extern int second_parser_pass(__nis_table_mapping_t **table_mapping);
590*7c478bd9Sstevel@tonic-gate extern int final_parser_pass(__nis_table_mapping_t **table_mapping,
591*7c478bd9Sstevel@tonic-gate 	__yp_domain_context_t   *ypDomains);
592*7c478bd9Sstevel@tonic-gate extern int finish_parse(__nis_ldap_proxy_info *proxy_info,
593*7c478bd9Sstevel@tonic-gate     __nis_table_mapping_t **table_mapping);
594*7c478bd9Sstevel@tonic-gate extern void set_default_values(__nis_ldap_proxy_info *proxy_info,
595*7c478bd9Sstevel@tonic-gate     __nis_config_t *config_info, __nisdb_table_mapping_t *table_info);
596*7c478bd9Sstevel@tonic-gate 
597*7c478bd9Sstevel@tonic-gate extern int add_config_attribute(config_key attrib_num, const char *attrib_val,
598*7c478bd9Sstevel@tonic-gate     int attrib_len, __nis_config_info_t *config_info);
599*7c478bd9Sstevel@tonic-gate extern int add_bind_attribute(config_key attrib_num, const char *attrib_val,
600*7c478bd9Sstevel@tonic-gate     int attrib_len, __nis_ldap_proxy_info *proxy_info);
601*7c478bd9Sstevel@tonic-gate extern int add_operation_attribute(config_key attrib_num,
602*7c478bd9Sstevel@tonic-gate     const char *attrib_val, int attrib_len, __nis_config_t *config_info,
603*7c478bd9Sstevel@tonic-gate     __nisdb_table_mapping_t *table_info);
604*7c478bd9Sstevel@tonic-gate extern int add_mapping_attribute(config_key attrib_num, const char *attrib_val,
605*7c478bd9Sstevel@tonic-gate     int attrib_len, __nis_table_mapping_t **table_mapping);
606*7c478bd9Sstevel@tonic-gate extern int add_ypdomains_attribute(config_key attrib_num,
607*7c478bd9Sstevel@tonic-gate 	const char *attrib_val, int attrib_len,
608*7c478bd9Sstevel@tonic-gate 	__yp_domain_context_t *ypDomains);
609*7c478bd9Sstevel@tonic-gate extern config_key get_attrib_num(const char *s, int n);
610*7c478bd9Sstevel@tonic-gate bool_t is_cmd_line_option(config_key a_num);
611*7c478bd9Sstevel@tonic-gate 
612*7c478bd9Sstevel@tonic-gate extern const char *
613*7c478bd9Sstevel@tonic-gate skip_get_dn(const char *dn, const char *end);
614*7c478bd9Sstevel@tonic-gate extern const char *get_search_triple(const char *s, const char *end_s,
615*7c478bd9Sstevel@tonic-gate     __nis_search_triple_t *triple);
616*7c478bd9Sstevel@tonic-gate extern bool_t parse_index(const char *s, const char *end_s,
617*7c478bd9Sstevel@tonic-gate     __nis_index_t *index);
618*7c478bd9Sstevel@tonic-gate extern bool_t add_element(__nis_mapping_element_t *e,
619*7c478bd9Sstevel@tonic-gate     __nis_mapping_rlhs_t *m);
620*7c478bd9Sstevel@tonic-gate extern const char *skip_token(const char *s, const char *end_s,
621*7c478bd9Sstevel@tonic-gate     token_type t);
622*7c478bd9Sstevel@tonic-gate extern const char *get_next_extract_format_item(const char *begin_fmt,
623*7c478bd9Sstevel@tonic-gate     const char *end_fmt, __nis_mapping_format_t *fmt);
624*7c478bd9Sstevel@tonic-gate extern const char *get_next_print_format_item(const char *begin_fmt,
625*7c478bd9Sstevel@tonic-gate     const char *end_fmt, __nis_mapping_format_t *fmt);
626*7c478bd9Sstevel@tonic-gate extern const char *get_next_token(const char **begin_token,
627*7c478bd9Sstevel@tonic-gate     const char **end_token, token_type *t);
628*7c478bd9Sstevel@tonic-gate extern const char *get_next_object_dn_token(const char **begin_ret,
629*7c478bd9Sstevel@tonic-gate     const char **end_ret, object_dn_token *token);
630*7c478bd9Sstevel@tonic-gate extern const char *get_ldap_filter(const char **begin, const char **end);
631*7c478bd9Sstevel@tonic-gate const char *get_ava_list(const char **begin, const char **end,
632*7c478bd9Sstevel@tonic-gate 	bool_t end_nisplus);
633*7c478bd9Sstevel@tonic-gate 
634*7c478bd9Sstevel@tonic-gate extern  void  init_yptol_flag();
635*7c478bd9Sstevel@tonic-gate /* Utility functions */
636*7c478bd9Sstevel@tonic-gate extern char *s_strndup_esc(const char *s, int n);
637*7c478bd9Sstevel@tonic-gate extern char *s_strndup(const char *s, int n);
638*7c478bd9Sstevel@tonic-gate extern char *s_strdup(const char *s);
639*7c478bd9Sstevel@tonic-gate extern void *s_calloc(size_t n, size_t size);
640*7c478bd9Sstevel@tonic-gate extern void *s_realloc(void *s, size_t size);
641*7c478bd9Sstevel@tonic-gate extern bool_t is_whitespace(int c);
642*7c478bd9Sstevel@tonic-gate extern bool_t contains_string(const char *s1, const char *s2);
643*7c478bd9Sstevel@tonic-gate extern const char *skip_string(const char *s1, const char *s2, int len);
644*7c478bd9Sstevel@tonic-gate extern bool_t same_string(const char *s1, const char *s2, int len);
645*7c478bd9Sstevel@tonic-gate 
646*7c478bd9Sstevel@tonic-gate /* Error and information reporting functions */
647*7c478bd9Sstevel@tonic-gate extern void report_error(const char *str, const char *attr);
648*7c478bd9Sstevel@tonic-gate extern void report_error2(const char *str1, const char *str2);
649*7c478bd9Sstevel@tonic-gate extern void report_info(const char *str, const char *arg);
650*7c478bd9Sstevel@tonic-gate extern void report_conn_error(conn_error e, const char *str1, const char *str2);
651*7c478bd9Sstevel@tonic-gate extern void warn_duplicate_map(const char *db_id, config_key attrib_num);
652*7c478bd9Sstevel@tonic-gate 
653*7c478bd9Sstevel@tonic-gate /* Validation functions */
654*7c478bd9Sstevel@tonic-gate extern bool_t validate_dn(const char *s, int len);
655*7c478bd9Sstevel@tonic-gate extern bool_t validate_ldap_filter(const char *s, const char *end);
656*7c478bd9Sstevel@tonic-gate 
657*7c478bd9Sstevel@tonic-gate extern int			start_line_num;
658*7c478bd9Sstevel@tonic-gate extern int			cur_line_num;
659*7c478bd9Sstevel@tonic-gate extern int			seq_num;
660*7c478bd9Sstevel@tonic-gate extern parse_error		p_error;
661*7c478bd9Sstevel@tonic-gate extern char			_key_val[38];
662*7c478bd9Sstevel@tonic-gate extern const char		*command_line_source;
663*7c478bd9Sstevel@tonic-gate extern const char		*file_source;
664*7c478bd9Sstevel@tonic-gate extern const char		*ldap_source;
665*7c478bd9Sstevel@tonic-gate extern const char		*warn_file;
666*7c478bd9Sstevel@tonic-gate 
667*7c478bd9Sstevel@tonic-gate /* SSL and sasl-digest md5 functions */
668*7c478bd9Sstevel@tonic-gate int ldapssl_client_init(const char *certdbpath, void *certdbhandle);
669*7c478bd9Sstevel@tonic-gate const char *ldapssl_err2string(const int prerrno);
670*7c478bd9Sstevel@tonic-gate LDAP *ldapssl_init(const char *defhost, int defport, int defsecure);
671*7c478bd9Sstevel@tonic-gate int ldap_x_sasl_digest_md5_bind_s(LDAP *ld, char *user_name,
672*7c478bd9Sstevel@tonic-gate 	struct berval *cred,
673*7c478bd9Sstevel@tonic-gate 	LDAPControl **serverctrls, LDAPControl **clientctrls);
674*7c478bd9Sstevel@tonic-gate 
675*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
676*7c478bd9Sstevel@tonic-gate }
677*7c478bd9Sstevel@tonic-gate #endif
678*7c478bd9Sstevel@tonic-gate 
679*7c478bd9Sstevel@tonic-gate #endif	/* _NIS_PARSE_LDAP_CONF_H */
680