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