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