17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
54a190493Ssdussud * Common Development and Distribution License (the "License").
64a190493Ssdussud * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*a87701e9SGary Mills * Copyright 2015 Gary Mills
23b9175c69SKenjiro Tsuji * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <stdio.h>
287c478bd9Sstevel@tonic-gate #include <string.h>
297c478bd9Sstevel@tonic-gate #include <stdlib.h>
307c478bd9Sstevel@tonic-gate #include <ctype.h>
317c478bd9Sstevel@tonic-gate #include <fcntl.h>
327c478bd9Sstevel@tonic-gate #include <unistd.h>
337c478bd9Sstevel@tonic-gate #include <errno.h>
347c478bd9Sstevel@tonic-gate #include <locale.h>
357c478bd9Sstevel@tonic-gate #include <sys/stat.h>
367c478bd9Sstevel@tonic-gate #include <lber.h>
377c478bd9Sstevel@tonic-gate #include <ldap.h>
387c478bd9Sstevel@tonic-gate #include <deflt.h>
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate #include "ldap_map.h"
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #include "ldap_parse.h"
437c478bd9Sstevel@tonic-gate #include "ldap_glob.h"
447c478bd9Sstevel@tonic-gate #include "nis_parse_ldap_conf.h"
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info proxyInfo =
477c478bd9Sstevel@tonic-gate {NULL, (auth_method_t)NO_VALUE_SET, (tls_method_t)NO_VALUE_SET, NULL,
487c478bd9Sstevel@tonic-gate NULL, NULL, NULL, NULL, (follow_referral_t)NO_VALUE_SET};
497c478bd9Sstevel@tonic-gate __nis_config_t ldapConfig;
507c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t ldapDBTableMapping;
517c478bd9Sstevel@tonic-gate __nis_table_mapping_t *ldapTableMapping = NULL;
527c478bd9Sstevel@tonic-gate __yp_domain_context_t ypDomains;
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate parse_error p_error = no_parse_error;
557c478bd9Sstevel@tonic-gate int cur_line_num = 0;
567c478bd9Sstevel@tonic-gate int start_line_num = 0;
577c478bd9Sstevel@tonic-gate int seq_num = 0;
587c478bd9Sstevel@tonic-gate const char *warn_file = NULL;
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate char _key_val[38];
617c478bd9Sstevel@tonic-gate const char *command_line_source = NULL;
627c478bd9Sstevel@tonic-gate const char *file_source = NULL;
637c478bd9Sstevel@tonic-gate const char *ldap_source = NULL;
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gate static
667c478bd9Sstevel@tonic-gate const char *const *cmdline_config = NULL;
677c478bd9Sstevel@tonic-gate static bool_t got_config_data = FALSE;
687c478bd9Sstevel@tonic-gate
697c478bd9Sstevel@tonic-gate /* high level parsing functions functions */
707c478bd9Sstevel@tonic-gate static int parse_ldap_cmd_line(const char *const *cmdline_options,
717c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info, __nis_config_t *nis_config,
727c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping, __nis_config_info_t *config_info,
737c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info);
747c478bd9Sstevel@tonic-gate static int parse_ldap_default_conf(__nis_ldap_proxy_info *proxy_info,
757c478bd9Sstevel@tonic-gate __nis_config_t *nis_config, __nis_config_info_t *config_info,
767c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info);
777c478bd9Sstevel@tonic-gate static int parse_ldap_config_file(const char *config_file,
787c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info, __nis_config_t *nis_config,
797c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping, __nis_config_info_t *config_info,
807c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info);
817c478bd9Sstevel@tonic-gate static int parse_ldap_config_dn_attrs(__nis_ldap_proxy_info *proxy_info,
827c478bd9Sstevel@tonic-gate __nis_config_t *nis_config, __nis_table_mapping_t **table_mapping,
837c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info, __nisdb_table_mapping_t *table_info);
847c478bd9Sstevel@tonic-gate static int yp_parse_ldap_default_conf(__nis_ldap_proxy_info *proxy_info,
857c478bd9Sstevel@tonic-gate __nis_config_t *nis_config, __nis_config_info_t *config_info,
867c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info);
877c478bd9Sstevel@tonic-gate
88*a87701e9SGary Mills /* Forward declarations */
89*a87701e9SGary Mills int yp_parse_ldap_config_file(const char *, __nis_ldap_proxy_info *,
90*a87701e9SGary Mills __nis_config_t *, __nis_table_mapping_t **, __nis_config_info_t *,
91*a87701e9SGary Mills __nisdb_table_mapping_t *, __yp_domain_context_t *);
92*a87701e9SGary Mills
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate /* helper functions */
957c478bd9Sstevel@tonic-gate static config_key get_attrib_num_cmdline(const char *s,
967c478bd9Sstevel@tonic-gate const char **begin_s, const char **end_s);
977c478bd9Sstevel@tonic-gate static config_key get_file_attr_val(int fd, char **attr_val);
987c478bd9Sstevel@tonic-gate static void get_attribute_list(
997c478bd9Sstevel@tonic-gate const __nis_ldap_proxy_info *proxy_info,
1007c478bd9Sstevel@tonic-gate const __nis_config_t *nis_config,
1017c478bd9Sstevel@tonic-gate const __nis_config_info_t *config_info,
1027c478bd9Sstevel@tonic-gate const __nisdb_table_mapping_t *table_info,
1037c478bd9Sstevel@tonic-gate char **ldap_config_attributes);
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate * FUNCTION: parse_ldap_migration
1077c478bd9Sstevel@tonic-gate *
1087c478bd9Sstevel@tonic-gate * Parses the information for LDAP. The values are first
1097c478bd9Sstevel@tonic-gate * obtained from the command line, secondly from the preference
1107c478bd9Sstevel@tonic-gate * file, and finally from an LDAP profile (if so configured in
1117c478bd9Sstevel@tonic-gate * the command line or preference file). Any unset values will
1127c478bd9Sstevel@tonic-gate * be set to their default values.
1137c478bd9Sstevel@tonic-gate *
1147c478bd9Sstevel@tonic-gate * If no command line options, no settings in the /etc/default
1157c478bd9Sstevel@tonic-gate * configuration file, and no mapping file, then no mapping
1167c478bd9Sstevel@tonic-gate * should be used.
1177c478bd9Sstevel@tonic-gate *
1187c478bd9Sstevel@tonic-gate * RETURN VALUE:
1197c478bd9Sstevel@tonic-gate * 0 Success
1207c478bd9Sstevel@tonic-gate * -1 Config file stat/open or parse error
1217c478bd9Sstevel@tonic-gate * 1 No mapping should be used.
1227c478bd9Sstevel@tonic-gate *
1237c478bd9Sstevel@tonic-gate * INPUT: command line parameters, configuration file
1247c478bd9Sstevel@tonic-gate */
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate int
parse_ldap_migration(const char * const * cmdline_options,const char * config_file)1277c478bd9Sstevel@tonic-gate parse_ldap_migration(
1287c478bd9Sstevel@tonic-gate const char *const *cmdline_options,
1297c478bd9Sstevel@tonic-gate const char *config_file)
1307c478bd9Sstevel@tonic-gate {
1317c478bd9Sstevel@tonic-gate int rc = 0;
1327c478bd9Sstevel@tonic-gate __nis_config_info_t config_info
1337c478bd9Sstevel@tonic-gate = {NULL, NULL, (auth_method_t)NO_VALUE_SET,
1347c478bd9Sstevel@tonic-gate (tls_method_t)NO_VALUE_SET, NULL,
1357c478bd9Sstevel@tonic-gate NULL, NULL};
1367c478bd9Sstevel@tonic-gate struct stat buf;
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate p_error = no_parse_error;
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate if (verbose)
1417c478bd9Sstevel@tonic-gate report_info("Getting LDAP configuration", NULL);
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate initialize_parse_structs(&proxyInfo, &ldapConfig, &ldapDBTableMapping);
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate if (yp2ldap)
1467c478bd9Sstevel@tonic-gate initialize_yp_parse_structs(&ypDomains);
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate if (cmdline_options != NULL) {
1497c478bd9Sstevel@tonic-gate got_config_data = TRUE;
1507c478bd9Sstevel@tonic-gate /* NIS to LDAP does not read command line attributes */
1517c478bd9Sstevel@tonic-gate if (!yp2ldap)
1527c478bd9Sstevel@tonic-gate rc = parse_ldap_cmd_line(cmdline_options, &proxyInfo,
1537c478bd9Sstevel@tonic-gate &ldapConfig, &ldapTableMapping, &config_info,
1547c478bd9Sstevel@tonic-gate &ldapDBTableMapping);
1557c478bd9Sstevel@tonic-gate else
1567c478bd9Sstevel@tonic-gate rc = 0;
1577c478bd9Sstevel@tonic-gate }
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate if (rc == 0) {
1607c478bd9Sstevel@tonic-gate if (yp2ldap)
1617c478bd9Sstevel@tonic-gate rc = yp_parse_ldap_default_conf(&proxyInfo, &ldapConfig,
1627c478bd9Sstevel@tonic-gate &config_info, &ldapDBTableMapping);
1637c478bd9Sstevel@tonic-gate else
1647c478bd9Sstevel@tonic-gate rc = parse_ldap_default_conf(&proxyInfo, &ldapConfig,
1657c478bd9Sstevel@tonic-gate &config_info, &ldapDBTableMapping);
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate if (config_file == NULL) {
1697c478bd9Sstevel@tonic-gate if (yp2ldap) {
1707c478bd9Sstevel@tonic-gate if (stat(YP_DEFAULT_MAPPING_FILE, &buf) == 0)
1717c478bd9Sstevel@tonic-gate config_file = YP_DEFAULT_MAPPING_FILE;
1727c478bd9Sstevel@tonic-gate } else {
1737c478bd9Sstevel@tonic-gate if (stat(DEFAULT_MAPPING_FILE, &buf) == 0)
1747c478bd9Sstevel@tonic-gate config_file = DEFAULT_MAPPING_FILE;
1757c478bd9Sstevel@tonic-gate }
1767c478bd9Sstevel@tonic-gate }
1777c478bd9Sstevel@tonic-gate
1787c478bd9Sstevel@tonic-gate if (rc == 0 && config_file != NULL) {
1797c478bd9Sstevel@tonic-gate got_config_data = TRUE;
1807c478bd9Sstevel@tonic-gate warn_file = config_file;
1817c478bd9Sstevel@tonic-gate cmdline_config = cmdline_options;
1827c478bd9Sstevel@tonic-gate if (yp2ldap)
1837c478bd9Sstevel@tonic-gate rc = yp_parse_ldap_config_file(config_file, &proxyInfo,
1847c478bd9Sstevel@tonic-gate &ldapConfig, &ldapTableMapping, &config_info,
1857c478bd9Sstevel@tonic-gate &ldapDBTableMapping, &ypDomains);
1867c478bd9Sstevel@tonic-gate else
1877c478bd9Sstevel@tonic-gate rc = parse_ldap_config_file(config_file, &proxyInfo,
1887c478bd9Sstevel@tonic-gate &ldapConfig, &ldapTableMapping, &config_info,
1897c478bd9Sstevel@tonic-gate &ldapDBTableMapping);
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate warn_file = NULL;
1927c478bd9Sstevel@tonic-gate cmdline_config = NULL;
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate if (rc == 0 && (config_info.config_dn != NULL) &&
1957c478bd9Sstevel@tonic-gate (config_info.config_dn[0] != '\0')) {
1967c478bd9Sstevel@tonic-gate rc = parse_ldap_config_dn_attrs(&proxyInfo,
1977c478bd9Sstevel@tonic-gate &ldapConfig, &ldapTableMapping, &config_info,
1987c478bd9Sstevel@tonic-gate &ldapDBTableMapping);
1997c478bd9Sstevel@tonic-gate }
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gate free_config_info(&config_info);
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate if (rc == 0 && got_config_data == FALSE)
2047c478bd9Sstevel@tonic-gate rc = 1;
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate set_default_values(&proxyInfo, &ldapConfig, &ldapDBTableMapping);
2077c478bd9Sstevel@tonic-gate
2087c478bd9Sstevel@tonic-gate if (yp2ldap == 1 && rc == 0) {
2097c478bd9Sstevel@tonic-gate rc = second_parser_pass(&ldapTableMapping);
2107c478bd9Sstevel@tonic-gate if (rc == 0)
2117c478bd9Sstevel@tonic-gate rc = final_parser_pass(&ldapTableMapping, &ypDomains);
2127c478bd9Sstevel@tonic-gate if (rc == -2)
2137c478bd9Sstevel@tonic-gate return (-1);
2147c478bd9Sstevel@tonic-gate }
2157c478bd9Sstevel@tonic-gate
2167c478bd9Sstevel@tonic-gate if (rc == 0)
2177c478bd9Sstevel@tonic-gate rc = finish_parse(&proxyInfo, &ldapTableMapping);
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate if (rc == 0)
2207c478bd9Sstevel@tonic-gate rc = linked2hash(ldapTableMapping);
2217c478bd9Sstevel@tonic-gate
2224a190493Ssdussud if ((rc == 0) && yptol_mode)
2234a190493Ssdussud rc = map_id_list_init();
2244a190493Ssdussud
2257c478bd9Sstevel@tonic-gate if (rc != 0) {
2267c478bd9Sstevel@tonic-gate free_parse_structs();
2277c478bd9Sstevel@tonic-gate } else if (verbose)
2287c478bd9Sstevel@tonic-gate report_info("LDAP configuration complete", NULL);
2297c478bd9Sstevel@tonic-gate return (rc);
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate * FUNCTION: parse_ldap_cmd_line
2347c478bd9Sstevel@tonic-gate *
2357c478bd9Sstevel@tonic-gate * Parses the information for LDAP from the command line
2367c478bd9Sstevel@tonic-gate *
2377c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
2387c478bd9Sstevel@tonic-gate *
2397c478bd9Sstevel@tonic-gate * INPUT: command line values
2407c478bd9Sstevel@tonic-gate */
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gate static int
parse_ldap_cmd_line(const char * const * cmdline_options,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)2437c478bd9Sstevel@tonic-gate parse_ldap_cmd_line(
2447c478bd9Sstevel@tonic-gate const char *const *cmdline_options,
2457c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
2467c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
2477c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
2487c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
2497c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
2507c478bd9Sstevel@tonic-gate {
2517c478bd9Sstevel@tonic-gate int rc = 0;
2527c478bd9Sstevel@tonic-gate config_key attrib_num;
2537c478bd9Sstevel@tonic-gate const char *begin_s;
2547c478bd9Sstevel@tonic-gate const char *end_s;
2557c478bd9Sstevel@tonic-gate
2567c478bd9Sstevel@tonic-gate if (verbose)
2577c478bd9Sstevel@tonic-gate report_info("Command line values: ", NULL);
2587c478bd9Sstevel@tonic-gate while (*cmdline_options != NULL) {
2597c478bd9Sstevel@tonic-gate if (verbose)
2607c478bd9Sstevel@tonic-gate report_info("\t", *cmdline_options);
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num_cmdline(
2637c478bd9Sstevel@tonic-gate *cmdline_options, &begin_s, &end_s);
2647c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
2657c478bd9Sstevel@tonic-gate command_line_source = "command line";
2667c478bd9Sstevel@tonic-gate report_error(*cmdline_options, NULL);
2677c478bd9Sstevel@tonic-gate command_line_source = NULL;
2687c478bd9Sstevel@tonic-gate rc = -1;
2697c478bd9Sstevel@tonic-gate break;
2707c478bd9Sstevel@tonic-gate } else if (IS_CONFIG_KEYWORD(attrib_num)) {
2717c478bd9Sstevel@tonic-gate rc = add_config_attribute(attrib_num,
2727c478bd9Sstevel@tonic-gate begin_s, end_s - begin_s, config_info);
2737c478bd9Sstevel@tonic-gate } else if (IS_BIND_INFO(attrib_num)) {
2747c478bd9Sstevel@tonic-gate rc = add_bind_attribute(attrib_num,
2757c478bd9Sstevel@tonic-gate begin_s, end_s - begin_s, proxy_info);
2767c478bd9Sstevel@tonic-gate } else if (IS_OPER_INFO(attrib_num)) {
2777c478bd9Sstevel@tonic-gate rc = add_operation_attribute(attrib_num,
2787c478bd9Sstevel@tonic-gate begin_s, end_s - begin_s, nis_config,
2797c478bd9Sstevel@tonic-gate table_info);
2807c478bd9Sstevel@tonic-gate } else {
2817c478bd9Sstevel@tonic-gate rc = add_mapping_attribute(attrib_num,
2827c478bd9Sstevel@tonic-gate begin_s, end_s - begin_s, table_mapping);
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate
2857c478bd9Sstevel@tonic-gate if (rc < 0) {
2867c478bd9Sstevel@tonic-gate command_line_source = "command line";
2877c478bd9Sstevel@tonic-gate report_error(begin_s, _key_val);
2887c478bd9Sstevel@tonic-gate command_line_source = NULL;
2897c478bd9Sstevel@tonic-gate break;
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate cmdline_options++;
2927c478bd9Sstevel@tonic-gate }
2937c478bd9Sstevel@tonic-gate return (rc);
2947c478bd9Sstevel@tonic-gate }
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate static int
parse_ldap_default_conf(__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)2977c478bd9Sstevel@tonic-gate parse_ldap_default_conf(
2987c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
2997c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
3007c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
3017c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
3027c478bd9Sstevel@tonic-gate {
3037c478bd9Sstevel@tonic-gate int rc = 0;
3047c478bd9Sstevel@tonic-gate char *ldap_config_attributes[n_config_keys];
3057c478bd9Sstevel@tonic-gate char attr_buf[128];
3067c478bd9Sstevel@tonic-gate char *attr;
307b9175c69SKenjiro Tsuji char *attr_val;
3087c478bd9Sstevel@tonic-gate int defflags;
3097c478bd9Sstevel@tonic-gate config_key attrib_num;
3107c478bd9Sstevel@tonic-gate int i;
3117c478bd9Sstevel@tonic-gate int len;
3127c478bd9Sstevel@tonic-gate int attr_len;
313b9175c69SKenjiro Tsuji void *defp;
3147c478bd9Sstevel@tonic-gate
315b9175c69SKenjiro Tsuji if ((defp = defopen_r(ETCCONFFILE)) != NULL) {
3167c478bd9Sstevel@tonic-gate file_source = ETCCONFFILE;
3177c478bd9Sstevel@tonic-gate if (verbose)
318b9175c69SKenjiro Tsuji report_info("default configuration values: ", NULL);
319b9175c69SKenjiro Tsuji /* Set defread_r() to be case insensitive */
320b9175c69SKenjiro Tsuji defflags = defcntl_r(DC_GETFLAGS, 0, defp);
3217c478bd9Sstevel@tonic-gate TURNOFF(defflags, DC_CASE);
322b9175c69SKenjiro Tsuji (void) defcntl_r(DC_SETFLAGS, defflags, defp);
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate get_attribute_list(proxy_info, nis_config, config_info,
3257c478bd9Sstevel@tonic-gate table_info, ldap_config_attributes);
3267c478bd9Sstevel@tonic-gate i = 0;
3277c478bd9Sstevel@tonic-gate while ((attr = ldap_config_attributes[i++]) != NULL) {
328b9175c69SKenjiro Tsuji (void) strlcpy(attr_buf, attr, sizeof (attr_buf));
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate * if nisplusUpdateBatching, make sure
3317c478bd9Sstevel@tonic-gate * we don't match nisplusUpdateBatchingTimeout
3327c478bd9Sstevel@tonic-gate */
3337c478bd9Sstevel@tonic-gate if (strcmp(attr, UPDATE_BATCHING) == 0) {
3347c478bd9Sstevel@tonic-gate attr_len = strlen(attr);
3357c478bd9Sstevel@tonic-gate attr_buf[attr_len] = '=';
3367c478bd9Sstevel@tonic-gate attr_buf[attr_len + 1] = '\0';
337b9175c69SKenjiro Tsuji attr_val = defread_r(attr_buf, defp);
3387c478bd9Sstevel@tonic-gate
3397c478bd9Sstevel@tonic-gate if (attr_val == 0) {
3407c478bd9Sstevel@tonic-gate attr_buf[attr_len] = ' ';
341b9175c69SKenjiro Tsuji attr_val = defread_r(attr_buf, defp);
3427c478bd9Sstevel@tonic-gate }
3437c478bd9Sstevel@tonic-gate if (attr_val == 0) {
3447c478bd9Sstevel@tonic-gate attr_buf[attr_len] = '\t';
345b9175c69SKenjiro Tsuji attr_val = defread_r(attr_buf, defp);
3467c478bd9Sstevel@tonic-gate }
3477c478bd9Sstevel@tonic-gate if (attr_val == 0) {
3487c478bd9Sstevel@tonic-gate attr_buf[attr_len] = '\n';
349b9175c69SKenjiro Tsuji attr_val = defread_r(attr_buf, defp);
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate } else {
352b9175c69SKenjiro Tsuji attr_val = defread_r(attr_buf, defp);
3537c478bd9Sstevel@tonic-gate }
354b9175c69SKenjiro Tsuji if (attr_val == NULL)
3557c478bd9Sstevel@tonic-gate continue;
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate got_config_data = TRUE;
3587c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num(attr, strlen(attr));
3597c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
3607c478bd9Sstevel@tonic-gate report_error(attr, NULL);
3617c478bd9Sstevel@tonic-gate rc = -1;
3627c478bd9Sstevel@tonic-gate break;
3637c478bd9Sstevel@tonic-gate }
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate /*
3667c478bd9Sstevel@tonic-gate * Allow either entries of the form
3677c478bd9Sstevel@tonic-gate * attr val
3687c478bd9Sstevel@tonic-gate * or
3697c478bd9Sstevel@tonic-gate * attr = val
3707c478bd9Sstevel@tonic-gate */
3717c478bd9Sstevel@tonic-gate while (is_whitespace(*attr_val))
3727c478bd9Sstevel@tonic-gate attr_val++;
3737c478bd9Sstevel@tonic-gate if (*attr_val == '=')
3747c478bd9Sstevel@tonic-gate attr_val++;
3757c478bd9Sstevel@tonic-gate while (is_whitespace(*attr_val))
3767c478bd9Sstevel@tonic-gate attr_val++;
3777c478bd9Sstevel@tonic-gate len = strlen(attr_val);
378b9175c69SKenjiro Tsuji while (len > 0 && is_whitespace(attr_val[len - 1]))
3797c478bd9Sstevel@tonic-gate len--;
3807c478bd9Sstevel@tonic-gate
3817c478bd9Sstevel@tonic-gate if (verbose) {
3827c478bd9Sstevel@tonic-gate report_info("\t", attr);
3837c478bd9Sstevel@tonic-gate report_info("\t\t", attr_val);
3847c478bd9Sstevel@tonic-gate }
3857c478bd9Sstevel@tonic-gate if (IS_BIND_INFO(attrib_num)) {
3867c478bd9Sstevel@tonic-gate rc = add_bind_attribute(attrib_num,
3877c478bd9Sstevel@tonic-gate attr_val, len, proxy_info);
3887c478bd9Sstevel@tonic-gate } else if (IS_OPER_INFO(attrib_num)) {
3897c478bd9Sstevel@tonic-gate rc = add_operation_attribute(attrib_num,
3907c478bd9Sstevel@tonic-gate attr_val, len, nis_config,
3917c478bd9Sstevel@tonic-gate table_info);
3927c478bd9Sstevel@tonic-gate }
3937c478bd9Sstevel@tonic-gate if (p_error != no_parse_error) {
3947c478bd9Sstevel@tonic-gate report_error(attr_val, attr);
3957c478bd9Sstevel@tonic-gate rc = -1;
3967c478bd9Sstevel@tonic-gate break;
3977c478bd9Sstevel@tonic-gate }
3987c478bd9Sstevel@tonic-gate }
3997c478bd9Sstevel@tonic-gate file_source = NULL;
4007c478bd9Sstevel@tonic-gate /* Close the /etc/default file */
401b9175c69SKenjiro Tsuji defclose_r(defp);
4027c478bd9Sstevel@tonic-gate }
4037c478bd9Sstevel@tonic-gate return (rc);
4047c478bd9Sstevel@tonic-gate }
4057c478bd9Sstevel@tonic-gate
4067c478bd9Sstevel@tonic-gate static int
yp_parse_ldap_default_conf(__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)4077c478bd9Sstevel@tonic-gate yp_parse_ldap_default_conf(
4087c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
4097c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
4107c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
4117c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
4127c478bd9Sstevel@tonic-gate {
4137c478bd9Sstevel@tonic-gate int rc = 0;
4147c478bd9Sstevel@tonic-gate char *ldap_config_attributes[n_config_keys];
4157c478bd9Sstevel@tonic-gate char attr_buf[128];
4167c478bd9Sstevel@tonic-gate char *attr;
417b9175c69SKenjiro Tsuji char *attr_val;
4187c478bd9Sstevel@tonic-gate int defflags;
4197c478bd9Sstevel@tonic-gate config_key attrib_num;
420*a87701e9SGary Mills int i, len;
421b9175c69SKenjiro Tsuji void *defp;
4227c478bd9Sstevel@tonic-gate
423b9175c69SKenjiro Tsuji if ((defp = defopen_r(YP_ETCCONFFILE)) != NULL) {
4247c478bd9Sstevel@tonic-gate file_source = YP_ETCCONFFILE;
4257c478bd9Sstevel@tonic-gate if (verbose)
4267c478bd9Sstevel@tonic-gate report_info("default configuration values: ", NULL);
427b9175c69SKenjiro Tsuji /* Set defread_r() to be case insensitive */
428b9175c69SKenjiro Tsuji defflags = defcntl_r(DC_GETFLAGS, 0, defp);
4297c478bd9Sstevel@tonic-gate TURNOFF(defflags, DC_CASE);
430b9175c69SKenjiro Tsuji (void) defcntl_r(DC_SETFLAGS, defflags, defp);
4317c478bd9Sstevel@tonic-gate
4327c478bd9Sstevel@tonic-gate get_attribute_list(proxy_info, nis_config, config_info,
4337c478bd9Sstevel@tonic-gate table_info, ldap_config_attributes);
4347c478bd9Sstevel@tonic-gate i = 0;
4357c478bd9Sstevel@tonic-gate while ((attr = ldap_config_attributes[i++]) != NULL) {
436b9175c69SKenjiro Tsuji if ((strlcpy(attr_buf, attr, sizeof (attr_buf))) >=
4377c478bd9Sstevel@tonic-gate sizeof (attr_buf)) {
4387c478bd9Sstevel@tonic-gate report_error(
4397c478bd9Sstevel@tonic-gate "Static buffer attr_buf overflow", NULL);
440b9175c69SKenjiro Tsuji defclose_r(defp);
4417c478bd9Sstevel@tonic-gate return (-1);
4427c478bd9Sstevel@tonic-gate }
4437c478bd9Sstevel@tonic-gate
444b9175c69SKenjiro Tsuji if ((attr_val = defread_r(attr_buf, defp)) == NULL)
4457c478bd9Sstevel@tonic-gate continue;
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate got_config_data = TRUE;
4487c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num(attr, strlen(attr));
4497c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
4507c478bd9Sstevel@tonic-gate report_error(attr, NULL);
4517c478bd9Sstevel@tonic-gate rc = -1;
4527c478bd9Sstevel@tonic-gate break;
4537c478bd9Sstevel@tonic-gate }
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate /*
4567c478bd9Sstevel@tonic-gate * Allow either entries of the form
4577c478bd9Sstevel@tonic-gate * attr val
4587c478bd9Sstevel@tonic-gate * or
4597c478bd9Sstevel@tonic-gate * attr = val
4607c478bd9Sstevel@tonic-gate */
4617c478bd9Sstevel@tonic-gate while (is_whitespace(*attr_val))
4627c478bd9Sstevel@tonic-gate attr_val++;
4637c478bd9Sstevel@tonic-gate if (*attr_val == '=')
4647c478bd9Sstevel@tonic-gate attr_val++;
4657c478bd9Sstevel@tonic-gate while (is_whitespace(*attr_val))
4667c478bd9Sstevel@tonic-gate attr_val++;
4677c478bd9Sstevel@tonic-gate len = strlen(attr_val);
468b9175c69SKenjiro Tsuji while (len > 0 && is_whitespace(attr_val[len - 1]))
4697c478bd9Sstevel@tonic-gate len--;
4707c478bd9Sstevel@tonic-gate
4717c478bd9Sstevel@tonic-gate if (verbose) {
4727c478bd9Sstevel@tonic-gate report_info("\t", attr);
4737c478bd9Sstevel@tonic-gate report_info("\t\t", attr_val);
4747c478bd9Sstevel@tonic-gate }
4757c478bd9Sstevel@tonic-gate if (IS_YP_BIND_INFO(attrib_num)) {
4767c478bd9Sstevel@tonic-gate rc = add_bind_attribute(attrib_num,
4777c478bd9Sstevel@tonic-gate attr_val, len, proxy_info);
4787c478bd9Sstevel@tonic-gate } else if (IS_YP_OPER_INFO(attrib_num)) {
4797c478bd9Sstevel@tonic-gate rc = add_operation_attribute(attrib_num,
4807c478bd9Sstevel@tonic-gate attr_val, len, nis_config,
4817c478bd9Sstevel@tonic-gate table_info);
4827c478bd9Sstevel@tonic-gate }
4837c478bd9Sstevel@tonic-gate if (p_error != no_parse_error) {
4847c478bd9Sstevel@tonic-gate report_error(attr_val, attr);
4857c478bd9Sstevel@tonic-gate rc = -1;
4867c478bd9Sstevel@tonic-gate break;
4877c478bd9Sstevel@tonic-gate }
4887c478bd9Sstevel@tonic-gate }
4897c478bd9Sstevel@tonic-gate file_source = NULL;
4907c478bd9Sstevel@tonic-gate /* Close the /etc/default file */
491b9175c69SKenjiro Tsuji defclose_r(defp);
4927c478bd9Sstevel@tonic-gate }
4937c478bd9Sstevel@tonic-gate return (rc);
4947c478bd9Sstevel@tonic-gate }
4957c478bd9Sstevel@tonic-gate
4967c478bd9Sstevel@tonic-gate /*
4977c478bd9Sstevel@tonic-gate * FUNCTION: get_attrib_num_cmdline
4987c478bd9Sstevel@tonic-gate *
4997c478bd9Sstevel@tonic-gate * Parses the information for LDAP from the command line
5007c478bd9Sstevel@tonic-gate * The form of the command line request is
5017c478bd9Sstevel@tonic-gate * -x attribute=value
5027c478bd9Sstevel@tonic-gate *
5037c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
5047c478bd9Sstevel@tonic-gate *
5057c478bd9Sstevel@tonic-gate * INPUT: command line values
5067c478bd9Sstevel@tonic-gate */
5077c478bd9Sstevel@tonic-gate
5087c478bd9Sstevel@tonic-gate static config_key
get_attrib_num_cmdline(const char * s,const char ** begin_s,const char ** end_s)5097c478bd9Sstevel@tonic-gate get_attrib_num_cmdline(
5107c478bd9Sstevel@tonic-gate const char *s,
5117c478bd9Sstevel@tonic-gate const char **begin_s,
5127c478bd9Sstevel@tonic-gate const char **end_s)
5137c478bd9Sstevel@tonic-gate {
5147c478bd9Sstevel@tonic-gate const char *s_end = s + strlen(s);
5157c478bd9Sstevel@tonic-gate const char *equal_s;
5167c478bd9Sstevel@tonic-gate const char *s1;
5177c478bd9Sstevel@tonic-gate config_key attrib_num;
5187c478bd9Sstevel@tonic-gate
5197c478bd9Sstevel@tonic-gate while (s < s_end && is_whitespace(*s))
5207c478bd9Sstevel@tonic-gate s++;
5217c478bd9Sstevel@tonic-gate
5227c478bd9Sstevel@tonic-gate for (equal_s = s; equal_s < s_end; equal_s++)
5237c478bd9Sstevel@tonic-gate if (*equal_s == EQUAL_CHAR)
5247c478bd9Sstevel@tonic-gate break;
5257c478bd9Sstevel@tonic-gate
5267c478bd9Sstevel@tonic-gate if (equal_s == s_end) {
5277c478bd9Sstevel@tonic-gate p_error = parse_bad_command_line_attribute_format;
5287c478bd9Sstevel@tonic-gate return (key_bad);
5297c478bd9Sstevel@tonic-gate }
5307c478bd9Sstevel@tonic-gate
5317c478bd9Sstevel@tonic-gate for (s1 = equal_s; s1 > s && is_whitespace(s1[-1]); s1--)
5327c478bd9Sstevel@tonic-gate ;
5337c478bd9Sstevel@tonic-gate
5347c478bd9Sstevel@tonic-gate if (s1 == s) {
5357c478bd9Sstevel@tonic-gate p_error = parse_bad_command_line_attribute_format;
5367c478bd9Sstevel@tonic-gate return (key_bad);
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate
5397c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num(s, s1 - s);
5407c478bd9Sstevel@tonic-gate
5417c478bd9Sstevel@tonic-gate if (attrib_num != key_bad) {
5427c478bd9Sstevel@tonic-gate s1 = equal_s + 1;
5437c478bd9Sstevel@tonic-gate while (s1 < s_end && is_whitespace(*s1))
5447c478bd9Sstevel@tonic-gate s1++;
5457c478bd9Sstevel@tonic-gate *begin_s = s1;
5467c478bd9Sstevel@tonic-gate while (s_end > s1 && is_whitespace(s_end[-1]))
5477c478bd9Sstevel@tonic-gate s_end--;
5487c478bd9Sstevel@tonic-gate *end_s = s_end;
5497c478bd9Sstevel@tonic-gate }
5507c478bd9Sstevel@tonic-gate
5517c478bd9Sstevel@tonic-gate return (attrib_num);
5527c478bd9Sstevel@tonic-gate }
5537c478bd9Sstevel@tonic-gate
5547c478bd9Sstevel@tonic-gate /*
5557c478bd9Sstevel@tonic-gate * FUNCTION: parse_ldap_config_file
5567c478bd9Sstevel@tonic-gate *
5577c478bd9Sstevel@tonic-gate * Parses the information for LDAP from a configuration
5587c478bd9Sstevel@tonic-gate * file. If no file is specified, /var/nis/NIS+LDAPmapping
5597c478bd9Sstevel@tonic-gate * is used
5607c478bd9Sstevel@tonic-gate *
5617c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
5627c478bd9Sstevel@tonic-gate *
5637c478bd9Sstevel@tonic-gate * INPUT: configuration file name
5647c478bd9Sstevel@tonic-gate */
5657c478bd9Sstevel@tonic-gate
5667c478bd9Sstevel@tonic-gate static int
parse_ldap_config_file(const char * config_file,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)5677c478bd9Sstevel@tonic-gate parse_ldap_config_file(
5687c478bd9Sstevel@tonic-gate const char *config_file,
5697c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
5707c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
5717c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
5727c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
5737c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
5747c478bd9Sstevel@tonic-gate {
5757c478bd9Sstevel@tonic-gate int rc = 0;
5767c478bd9Sstevel@tonic-gate config_key attrib_num;
5777c478bd9Sstevel@tonic-gate int fd;
5787c478bd9Sstevel@tonic-gate char *attr_val;
5797c478bd9Sstevel@tonic-gate int len;
5807c478bd9Sstevel@tonic-gate
5817c478bd9Sstevel@tonic-gate if ((fd = open(config_file, O_RDONLY)) == -1) {
5827c478bd9Sstevel@tonic-gate p_error = parse_open_file_error;
5837c478bd9Sstevel@tonic-gate report_error(config_file, NULL);
5847c478bd9Sstevel@tonic-gate return (-1);
5857c478bd9Sstevel@tonic-gate }
5867c478bd9Sstevel@tonic-gate
5877c478bd9Sstevel@tonic-gate start_line_num = 1;
5887c478bd9Sstevel@tonic-gate cur_line_num = 1;
5897c478bd9Sstevel@tonic-gate
5907c478bd9Sstevel@tonic-gate if (verbose)
5917c478bd9Sstevel@tonic-gate report_info("Reading configuration from ", config_file);
5927c478bd9Sstevel@tonic-gate
5937c478bd9Sstevel@tonic-gate file_source = config_file;
5947c478bd9Sstevel@tonic-gate while ((attrib_num = get_file_attr_val(fd, &attr_val)) > 0) {
5957c478bd9Sstevel@tonic-gate len = attr_val == NULL ? 0 : strlen(attr_val);
5967c478bd9Sstevel@tonic-gate if (IS_CONFIG_KEYWORD(attrib_num)) {
5977c478bd9Sstevel@tonic-gate rc = add_config_attribute(attrib_num,
5987c478bd9Sstevel@tonic-gate attr_val, len, config_info);
5997c478bd9Sstevel@tonic-gate } else if (IS_BIND_INFO(attrib_num)) {
6007c478bd9Sstevel@tonic-gate rc = add_bind_attribute(attrib_num,
6017c478bd9Sstevel@tonic-gate attr_val, len, proxy_info);
6027c478bd9Sstevel@tonic-gate } else if (IS_OPER_INFO(attrib_num)) {
6037c478bd9Sstevel@tonic-gate rc = add_operation_attribute(attrib_num,
6047c478bd9Sstevel@tonic-gate attr_val, len, nis_config, table_info);
6057c478bd9Sstevel@tonic-gate } else {
6067c478bd9Sstevel@tonic-gate rc = add_mapping_attribute(attrib_num,
6077c478bd9Sstevel@tonic-gate attr_val, len, table_mapping);
6087c478bd9Sstevel@tonic-gate }
6097c478bd9Sstevel@tonic-gate
6107c478bd9Sstevel@tonic-gate if (rc < 0) {
6117c478bd9Sstevel@tonic-gate report_error(attr_val == NULL ?
6127c478bd9Sstevel@tonic-gate "<no attribute>" : attr_val, _key_val);
6137c478bd9Sstevel@tonic-gate if (attr_val)
6147c478bd9Sstevel@tonic-gate free(attr_val);
6157c478bd9Sstevel@tonic-gate break;
6167c478bd9Sstevel@tonic-gate }
6177c478bd9Sstevel@tonic-gate if (attr_val)
6187c478bd9Sstevel@tonic-gate free(attr_val);
6197c478bd9Sstevel@tonic-gate }
6207c478bd9Sstevel@tonic-gate
6217c478bd9Sstevel@tonic-gate (void) close(fd);
6227c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
6237c478bd9Sstevel@tonic-gate report_error(_key_val, NULL);
6247c478bd9Sstevel@tonic-gate rc = -1;
6257c478bd9Sstevel@tonic-gate }
6267c478bd9Sstevel@tonic-gate start_line_num = 0;
6277c478bd9Sstevel@tonic-gate file_source = NULL;
6287c478bd9Sstevel@tonic-gate return (rc);
6297c478bd9Sstevel@tonic-gate }
6307c478bd9Sstevel@tonic-gate
6317c478bd9Sstevel@tonic-gate /*
6327c478bd9Sstevel@tonic-gate * FUNCTION: yp_parse_ldap_config_file
6337c478bd9Sstevel@tonic-gate *
6347c478bd9Sstevel@tonic-gate * Parses the information for LDAP from a configuration
6357c478bd9Sstevel@tonic-gate * file. If no file is specified, /var/yp/NISLDAPmapping
6367c478bd9Sstevel@tonic-gate * is used
6377c478bd9Sstevel@tonic-gate *
6387c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
6397c478bd9Sstevel@tonic-gate *
6407c478bd9Sstevel@tonic-gate * INPUT: configuration file name
6417c478bd9Sstevel@tonic-gate */
6427c478bd9Sstevel@tonic-gate
6437c478bd9Sstevel@tonic-gate int
yp_parse_ldap_config_file(const char * config_file,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info,__yp_domain_context_t * ypDomains)6447c478bd9Sstevel@tonic-gate yp_parse_ldap_config_file(
6457c478bd9Sstevel@tonic-gate const char *config_file,
6467c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
6477c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
6487c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
6497c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
6507c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info,
6517c478bd9Sstevel@tonic-gate __yp_domain_context_t *ypDomains)
6527c478bd9Sstevel@tonic-gate {
6537c478bd9Sstevel@tonic-gate int rc = 0;
6547c478bd9Sstevel@tonic-gate config_key attrib_num;
6557c478bd9Sstevel@tonic-gate int fd;
6567c478bd9Sstevel@tonic-gate char *attr_val = NULL;
6577c478bd9Sstevel@tonic-gate int len;
6587c478bd9Sstevel@tonic-gate
6597c478bd9Sstevel@tonic-gate if ((fd = open(config_file, O_RDONLY)) == -1) {
6607c478bd9Sstevel@tonic-gate p_error = parse_open_file_error;
6617c478bd9Sstevel@tonic-gate report_error(config_file, NULL);
6627c478bd9Sstevel@tonic-gate return (-1);
6637c478bd9Sstevel@tonic-gate }
6647c478bd9Sstevel@tonic-gate
6657c478bd9Sstevel@tonic-gate start_line_num = 1;
6667c478bd9Sstevel@tonic-gate cur_line_num = 1;
6677c478bd9Sstevel@tonic-gate
6687c478bd9Sstevel@tonic-gate if (verbose)
6697c478bd9Sstevel@tonic-gate report_info("Reading configuration from ", config_file);
6707c478bd9Sstevel@tonic-gate
6717c478bd9Sstevel@tonic-gate file_source = config_file;
6727c478bd9Sstevel@tonic-gate while ((attrib_num = get_file_attr_val(fd, &attr_val)) > 0) {
6737c478bd9Sstevel@tonic-gate len = attr_val == NULL ? 0 : strlen(attr_val);
6747c478bd9Sstevel@tonic-gate if (IS_YP_CONFIG_KEYWORD(attrib_num)) {
6757c478bd9Sstevel@tonic-gate rc = add_config_attribute(attrib_num,
6767c478bd9Sstevel@tonic-gate attr_val, len, config_info);
6777c478bd9Sstevel@tonic-gate } else if (IS_YP_BIND_INFO(attrib_num)) {
6787c478bd9Sstevel@tonic-gate rc = add_bind_attribute(attrib_num,
6797c478bd9Sstevel@tonic-gate attr_val, len, proxy_info);
6807c478bd9Sstevel@tonic-gate } else if (IS_YP_OPER_INFO(attrib_num)) {
6817c478bd9Sstevel@tonic-gate rc = add_operation_attribute(attrib_num,
6827c478bd9Sstevel@tonic-gate attr_val, len, nis_config, table_info);
6837c478bd9Sstevel@tonic-gate } else if (IS_YP_DOMAIN_INFO(attrib_num)) {
6847c478bd9Sstevel@tonic-gate rc = add_ypdomains_attribute(attrib_num,
6857c478bd9Sstevel@tonic-gate attr_val, len, ypDomains);
6867c478bd9Sstevel@tonic-gate } else if (IS_YP_MAP_ATTR(attrib_num)) {
6877c478bd9Sstevel@tonic-gate rc = add_mapping_attribute(attrib_num,
6887c478bd9Sstevel@tonic-gate attr_val, len, table_mapping);
6897c478bd9Sstevel@tonic-gate } else {
6907c478bd9Sstevel@tonic-gate rc = -1;
6917c478bd9Sstevel@tonic-gate p_error = parse_unsupported_format;
6927c478bd9Sstevel@tonic-gate }
6937c478bd9Sstevel@tonic-gate
6947c478bd9Sstevel@tonic-gate if (rc < 0) {
6957c478bd9Sstevel@tonic-gate report_error(attr_val == NULL ?
6967c478bd9Sstevel@tonic-gate "<no attribute>" : attr_val, _key_val);
6977c478bd9Sstevel@tonic-gate if (attr_val)
6987c478bd9Sstevel@tonic-gate free(attr_val);
6997c478bd9Sstevel@tonic-gate break;
7007c478bd9Sstevel@tonic-gate }
7017c478bd9Sstevel@tonic-gate if (attr_val) {
7027c478bd9Sstevel@tonic-gate free(attr_val);
7037c478bd9Sstevel@tonic-gate attr_val = NULL;
7047c478bd9Sstevel@tonic-gate }
7057c478bd9Sstevel@tonic-gate }
7067c478bd9Sstevel@tonic-gate
7077c478bd9Sstevel@tonic-gate (void) close(fd);
7087c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
7097c478bd9Sstevel@tonic-gate report_error(_key_val, NULL);
7107c478bd9Sstevel@tonic-gate rc = -1;
7117c478bd9Sstevel@tonic-gate }
7127c478bd9Sstevel@tonic-gate start_line_num = 0;
7137c478bd9Sstevel@tonic-gate file_source = NULL;
7147c478bd9Sstevel@tonic-gate return (rc);
7157c478bd9Sstevel@tonic-gate }
7167c478bd9Sstevel@tonic-gate
7177c478bd9Sstevel@tonic-gate /*
7187c478bd9Sstevel@tonic-gate * FUNCTION: get_file_attr_val
7197c478bd9Sstevel@tonic-gate *
7207c478bd9Sstevel@tonic-gate * Gets the next attribute from the configuration file.
7217c478bd9Sstevel@tonic-gate *
7227c478bd9Sstevel@tonic-gate * RETURN VALUE: The config key if more attributes
7237c478bd9Sstevel@tonic-gate * no_more_keys if eof
7247c478bd9Sstevel@tonic-gate * key_bad if error
7257c478bd9Sstevel@tonic-gate */
7267c478bd9Sstevel@tonic-gate
7277c478bd9Sstevel@tonic-gate static config_key
get_file_attr_val(int fd,char ** attr_val)7287c478bd9Sstevel@tonic-gate get_file_attr_val(int fd, char **attr_val)
7297c478bd9Sstevel@tonic-gate {
7307c478bd9Sstevel@tonic-gate char buf[BUFSIZE];
7317c478bd9Sstevel@tonic-gate char *start_tag;
7327c478bd9Sstevel@tonic-gate char *start_val;
7337c478bd9Sstevel@tonic-gate char *end_val;
7347c478bd9Sstevel@tonic-gate char *cut_here;
7357c478bd9Sstevel@tonic-gate char *s;
7367c478bd9Sstevel@tonic-gate char *a;
7377c478bd9Sstevel@tonic-gate char *attribute_value;
7387c478bd9Sstevel@tonic-gate int ret;
7397c478bd9Sstevel@tonic-gate config_key attrib_num = no_more_keys;
7407c478bd9Sstevel@tonic-gate
7417c478bd9Sstevel@tonic-gate *attr_val = NULL;
7427c478bd9Sstevel@tonic-gate
7437c478bd9Sstevel@tonic-gate if ((ret = read_line(fd, buf, sizeof (buf))) > 0) {
7447c478bd9Sstevel@tonic-gate for (s = buf; is_whitespace(*s); s++)
7457c478bd9Sstevel@tonic-gate ;
7467c478bd9Sstevel@tonic-gate
7477c478bd9Sstevel@tonic-gate start_tag = s;
7487c478bd9Sstevel@tonic-gate while (*s != '\0' && !is_whitespace(*s))
7497c478bd9Sstevel@tonic-gate s++;
7507c478bd9Sstevel@tonic-gate
7517c478bd9Sstevel@tonic-gate if (verbose)
7527c478bd9Sstevel@tonic-gate report_info("\t", start_tag);
7537c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num(start_tag, s - start_tag);
7547c478bd9Sstevel@tonic-gate if (attrib_num == key_bad)
7557c478bd9Sstevel@tonic-gate return (key_bad);
7567c478bd9Sstevel@tonic-gate
7577c478bd9Sstevel@tonic-gate while (is_whitespace(*s))
7587c478bd9Sstevel@tonic-gate s++;
7597c478bd9Sstevel@tonic-gate if (*s == '\0')
7607c478bd9Sstevel@tonic-gate return (attrib_num);
7617c478bd9Sstevel@tonic-gate start_val = s;
7627c478bd9Sstevel@tonic-gate
7637c478bd9Sstevel@tonic-gate /* note that read_line will not return a line ending with \ */
7647c478bd9Sstevel@tonic-gate for (; *s != '\0'; s++) {
7657c478bd9Sstevel@tonic-gate if (*s == ESCAPE_CHAR)
7667c478bd9Sstevel@tonic-gate s++;
7677c478bd9Sstevel@tonic-gate }
7687c478bd9Sstevel@tonic-gate while (s > start_val && is_whitespace(s[-1]))
7697c478bd9Sstevel@tonic-gate s--;
7707c478bd9Sstevel@tonic-gate
7717c478bd9Sstevel@tonic-gate attribute_value =
772b9175c69SKenjiro Tsuji calloc(1, (size_t)(s - start_val) + 1);
7737c478bd9Sstevel@tonic-gate if (attribute_value == NULL) {
7747c478bd9Sstevel@tonic-gate p_error = parse_no_mem_error;
7757c478bd9Sstevel@tonic-gate return (key_bad);
7767c478bd9Sstevel@tonic-gate }
7777c478bd9Sstevel@tonic-gate attr_val[0] = attribute_value;
7787c478bd9Sstevel@tonic-gate
7797c478bd9Sstevel@tonic-gate a = *attr_val;
7807c478bd9Sstevel@tonic-gate end_val = s;
7817c478bd9Sstevel@tonic-gate cut_here = 0;
7827c478bd9Sstevel@tonic-gate for (s = start_val; s < end_val; s++) {
7837c478bd9Sstevel@tonic-gate if (*s == POUND_SIGN) {
7847c478bd9Sstevel@tonic-gate cut_here = s;
7857c478bd9Sstevel@tonic-gate while (s < end_val) {
7867c478bd9Sstevel@tonic-gate if (*s == DOUBLE_QUOTE_CHAR ||
7877c478bd9Sstevel@tonic-gate *s == SINGLE_QUOTE_CHAR) {
7887c478bd9Sstevel@tonic-gate cut_here = 0;
7897c478bd9Sstevel@tonic-gate break;
7907c478bd9Sstevel@tonic-gate }
7917c478bd9Sstevel@tonic-gate s++;
7927c478bd9Sstevel@tonic-gate }
7937c478bd9Sstevel@tonic-gate }
7947c478bd9Sstevel@tonic-gate }
7957c478bd9Sstevel@tonic-gate if (cut_here != 0)
7967c478bd9Sstevel@tonic-gate end_val = cut_here;
7977c478bd9Sstevel@tonic-gate
7987c478bd9Sstevel@tonic-gate for (s = start_val; s < end_val; s++)
7997c478bd9Sstevel@tonic-gate *a++ = *s;
8007c478bd9Sstevel@tonic-gate *a++ = '\0';
8017c478bd9Sstevel@tonic-gate }
8027c478bd9Sstevel@tonic-gate if (ret == -1)
8037c478bd9Sstevel@tonic-gate return (key_bad);
8047c478bd9Sstevel@tonic-gate
8057c478bd9Sstevel@tonic-gate return (attrib_num);
8067c478bd9Sstevel@tonic-gate }
8077c478bd9Sstevel@tonic-gate
8087c478bd9Sstevel@tonic-gate static LDAP *
connect_to_ldap_config_server(char * sever_name,int server_port,__nis_config_info_t * config_info)8097c478bd9Sstevel@tonic-gate connect_to_ldap_config_server(
8107c478bd9Sstevel@tonic-gate char *sever_name,
8117c478bd9Sstevel@tonic-gate int server_port,
8127c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info)
8137c478bd9Sstevel@tonic-gate {
8147c478bd9Sstevel@tonic-gate LDAP *ld = NULL;
8157c478bd9Sstevel@tonic-gate int ldapVersion = LDAP_VERSION3;
8167c478bd9Sstevel@tonic-gate int derefOption = LDAP_DEREF_ALWAYS;
8177c478bd9Sstevel@tonic-gate int timelimit = LDAP_NO_LIMIT;
8187c478bd9Sstevel@tonic-gate int sizelimit = LDAP_NO_LIMIT;
8197c478bd9Sstevel@tonic-gate int errnum;
8207c478bd9Sstevel@tonic-gate bool_t retrying = FALSE;
8217c478bd9Sstevel@tonic-gate int sleep_seconds = 1;
8227c478bd9Sstevel@tonic-gate struct berval cred;
8237c478bd9Sstevel@tonic-gate
8247c478bd9Sstevel@tonic-gate if (config_info->tls_method == no_tls) {
8257c478bd9Sstevel@tonic-gate ld = ldap_init(sever_name, server_port);
8267c478bd9Sstevel@tonic-gate if (ld == NULL) {
8277c478bd9Sstevel@tonic-gate p_error = parse_ldap_init_error;
8287c478bd9Sstevel@tonic-gate report_error(strerror(errno), NULL);
8297c478bd9Sstevel@tonic-gate return (NULL);
8307c478bd9Sstevel@tonic-gate }
8317c478bd9Sstevel@tonic-gate } else {
8327c478bd9Sstevel@tonic-gate if ((errnum = ldapssl_client_init(
8337c478bd9Sstevel@tonic-gate config_info->tls_cert_db, NULL)) < 0) {
8347c478bd9Sstevel@tonic-gate p_error = parse_ldapssl_client_init_error;
8357c478bd9Sstevel@tonic-gate report_error(ldapssl_err2string(errnum), NULL);
8367c478bd9Sstevel@tonic-gate return (NULL);
8377c478bd9Sstevel@tonic-gate }
8387c478bd9Sstevel@tonic-gate ld = ldapssl_init(sever_name, server_port, 1);
8397c478bd9Sstevel@tonic-gate if (ld == NULL) {
8407c478bd9Sstevel@tonic-gate p_error = parse_ldapssl_init_error;
8417c478bd9Sstevel@tonic-gate report_error(strerror(errno), NULL);
8427c478bd9Sstevel@tonic-gate return (NULL);
8437c478bd9Sstevel@tonic-gate }
8447c478bd9Sstevel@tonic-gate }
8457c478bd9Sstevel@tonic-gate
8467c478bd9Sstevel@tonic-gate (void) ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,
8477c478bd9Sstevel@tonic-gate &ldapVersion);
8487c478bd9Sstevel@tonic-gate (void) ldap_set_option(ld, LDAP_OPT_DEREF, &derefOption);
8497c478bd9Sstevel@tonic-gate (void) ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
8507c478bd9Sstevel@tonic-gate (void) ldap_set_option(ld, LDAP_OPT_TIMELIMIT, &timelimit);
8517c478bd9Sstevel@tonic-gate (void) ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
8527c478bd9Sstevel@tonic-gate
8537c478bd9Sstevel@tonic-gate /*
8547c478bd9Sstevel@tonic-gate * Attempt to bind to the LDAP server.
8557c478bd9Sstevel@tonic-gate * We will loop until success or until an error other
8567c478bd9Sstevel@tonic-gate * than LDAP_CONNECT_ERROR or LDAP_SERVER_DOWN
8577c478bd9Sstevel@tonic-gate */
8587c478bd9Sstevel@tonic-gate if (verbose)
8597c478bd9Sstevel@tonic-gate report_info("Connecting to ", sever_name);
8607c478bd9Sstevel@tonic-gate
8617c478bd9Sstevel@tonic-gate for (;;) {
8627c478bd9Sstevel@tonic-gate if (config_info->auth_method == simple) {
8637c478bd9Sstevel@tonic-gate errnum = ldap_simple_bind_s(ld, config_info->proxy_dn,
8647c478bd9Sstevel@tonic-gate config_info->proxy_passwd);
8657c478bd9Sstevel@tonic-gate } else if (config_info->auth_method == cram_md5) {
8667c478bd9Sstevel@tonic-gate cred.bv_len = strlen(config_info->proxy_passwd);
8677c478bd9Sstevel@tonic-gate cred.bv_val = config_info->proxy_passwd;
8687c478bd9Sstevel@tonic-gate errnum = ldap_sasl_cram_md5_bind_s(ld,
8697c478bd9Sstevel@tonic-gate config_info->proxy_dn, &cred, NULL, NULL);
8707c478bd9Sstevel@tonic-gate } else if (config_info->auth_method == digest_md5) {
8717c478bd9Sstevel@tonic-gate cred.bv_len = strlen(config_info->proxy_passwd);
8727c478bd9Sstevel@tonic-gate cred.bv_val = config_info->proxy_passwd;
8737c478bd9Sstevel@tonic-gate errnum = ldap_x_sasl_digest_md5_bind_s(ld,
8747c478bd9Sstevel@tonic-gate config_info->proxy_dn, &cred, NULL, NULL);
8757c478bd9Sstevel@tonic-gate } else {
8767c478bd9Sstevel@tonic-gate errnum = ldap_simple_bind_s(ld, NULL, NULL);
8777c478bd9Sstevel@tonic-gate }
8787c478bd9Sstevel@tonic-gate
8797c478bd9Sstevel@tonic-gate if (errnum == LDAP_SUCCESS)
8807c478bd9Sstevel@tonic-gate break;
8817c478bd9Sstevel@tonic-gate
8827c478bd9Sstevel@tonic-gate if (errnum == LDAP_CONNECT_ERROR ||
8837c478bd9Sstevel@tonic-gate errnum == LDAP_SERVER_DOWN) {
8847c478bd9Sstevel@tonic-gate if (!retrying) {
8857c478bd9Sstevel@tonic-gate if (verbose)
8867c478bd9Sstevel@tonic-gate report_info(
8877c478bd9Sstevel@tonic-gate "LDAP server unavailable. Retrying...",
8887c478bd9Sstevel@tonic-gate NULL);
8897c478bd9Sstevel@tonic-gate retrying = TRUE;
8907c478bd9Sstevel@tonic-gate }
8917c478bd9Sstevel@tonic-gate (void) sleep(sleep_seconds);
8927c478bd9Sstevel@tonic-gate sleep_seconds *= 2;
8937c478bd9Sstevel@tonic-gate if (sleep_seconds > MAX_LDAP_CONFIG_RETRY_TIME)
8947c478bd9Sstevel@tonic-gate sleep_seconds = MAX_LDAP_CONFIG_RETRY_TIME;
8957c478bd9Sstevel@tonic-gate p_error = no_parse_error;
8967c478bd9Sstevel@tonic-gate continue;
8977c478bd9Sstevel@tonic-gate }
8987c478bd9Sstevel@tonic-gate p_error = parse_ldap_bind_error;
8997c478bd9Sstevel@tonic-gate report_error2(config_info->proxy_dn, ldap_err2string(errnum));
9007c478bd9Sstevel@tonic-gate (void) ldap_unbind(ld);
9017c478bd9Sstevel@tonic-gate return (NULL);
9027c478bd9Sstevel@tonic-gate }
9037c478bd9Sstevel@tonic-gate
9047c478bd9Sstevel@tonic-gate if (verbose)
9057c478bd9Sstevel@tonic-gate report_info("Reading values from ", config_info->config_dn);
9067c478bd9Sstevel@tonic-gate
9077c478bd9Sstevel@tonic-gate return (ld);
9087c478bd9Sstevel@tonic-gate }
9097c478bd9Sstevel@tonic-gate
9107c478bd9Sstevel@tonic-gate /*
9117c478bd9Sstevel@tonic-gate * FUNCTION: process_ldap_config_result
9127c478bd9Sstevel@tonic-gate *
9137c478bd9Sstevel@tonic-gate * Extracts the LDAPMessage containing the nis+/LDAP
9147c478bd9Sstevel@tonic-gate * configuration
9157c478bd9Sstevel@tonic-gate *
9167c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
9177c478bd9Sstevel@tonic-gate *
9187c478bd9Sstevel@tonic-gate * INPUT: LDAP the LDAP connection
9197c478bd9Sstevel@tonic-gate * LDAPMessage the LDAP message
9207c478bd9Sstevel@tonic-gate */
9217c478bd9Sstevel@tonic-gate
9227c478bd9Sstevel@tonic-gate static int
process_ldap_config_result(LDAP * ld,LDAPMessage * resultMsg,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nisdb_table_mapping_t * table_info)9237c478bd9Sstevel@tonic-gate process_ldap_config_result(
9247c478bd9Sstevel@tonic-gate LDAP *ld,
9257c478bd9Sstevel@tonic-gate LDAPMessage *resultMsg,
9267c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
9277c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
9287c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
9297c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
9307c478bd9Sstevel@tonic-gate {
9317c478bd9Sstevel@tonic-gate LDAPMessage *e;
9327c478bd9Sstevel@tonic-gate int errnum;
9337c478bd9Sstevel@tonic-gate char *attr;
9347c478bd9Sstevel@tonic-gate BerElement *ber = NULL;
9357c478bd9Sstevel@tonic-gate config_key attrib_num;
9367c478bd9Sstevel@tonic-gate char **vals;
9377c478bd9Sstevel@tonic-gate int n;
9387c478bd9Sstevel@tonic-gate int i;
9397c478bd9Sstevel@tonic-gate char *attr_val;
9407c478bd9Sstevel@tonic-gate int len;
9417c478bd9Sstevel@tonic-gate int rc = 0;
9427c478bd9Sstevel@tonic-gate bool_t error_reported = FALSE;
9437c478bd9Sstevel@tonic-gate
9447c478bd9Sstevel@tonic-gate e = ldap_first_entry(ld, resultMsg);
9457c478bd9Sstevel@tonic-gate
9467c478bd9Sstevel@tonic-gate if (e != NULL) {
947b9175c69SKenjiro Tsuji for (attr = ldap_first_attribute(ld, e, &ber); attr != NULL;
9487c478bd9Sstevel@tonic-gate attr = ldap_next_attribute(ld, e, ber)) {
9497c478bd9Sstevel@tonic-gate if (verbose)
9507c478bd9Sstevel@tonic-gate report_info("\t", attr);
9517c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num(attr, strlen(attr));
9527c478bd9Sstevel@tonic-gate if (attrib_num == key_bad) {
9537c478bd9Sstevel@tonic-gate report_error(attr, NULL);
9547c478bd9Sstevel@tonic-gate break;
9557c478bd9Sstevel@tonic-gate }
9567c478bd9Sstevel@tonic-gate if ((vals = ldap_get_values(ld, e, attr)) != NULL) {
9577c478bd9Sstevel@tonic-gate n = ldap_count_values(vals);
9587c478bd9Sstevel@tonic-gate /* parse the attribute values */
9597c478bd9Sstevel@tonic-gate for (i = 0; i < n; i++) {
9607c478bd9Sstevel@tonic-gate attr_val = vals[i];
9617c478bd9Sstevel@tonic-gate while (is_whitespace(*attr_val))
9627c478bd9Sstevel@tonic-gate attr_val++;
9637c478bd9Sstevel@tonic-gate if (verbose)
9647c478bd9Sstevel@tonic-gate report_info("\t\t", attr_val);
9657c478bd9Sstevel@tonic-gate len = strlen(attr_val);
9667c478bd9Sstevel@tonic-gate while (len > 0 &&
9677c478bd9Sstevel@tonic-gate is_whitespace(attr_val[len - 1]))
9687c478bd9Sstevel@tonic-gate len--;
9697c478bd9Sstevel@tonic-gate if (yp2ldap) {
9707c478bd9Sstevel@tonic-gate if (IS_YP_BIND_INFO(attrib_num)) {
971b9175c69SKenjiro Tsuji rc = add_bind_attribute(attrib_num, attr_val,
9727c478bd9Sstevel@tonic-gate len, proxy_info);
973b9175c69SKenjiro Tsuji } else if (IS_YP_OPER_INFO(attrib_num)) {
974b9175c69SKenjiro Tsuji rc = add_operation_attribute(attrib_num,
975b9175c69SKenjiro Tsuji attr_val, len, nis_config, table_info);
976b9175c69SKenjiro Tsuji } else if (IS_YP_MAP_ATTR(attrib_num)) {
977b9175c69SKenjiro Tsuji rc = add_mapping_attribute(attrib_num, attr_val,
978b9175c69SKenjiro Tsuji len, table_mapping);
9797c478bd9Sstevel@tonic-gate } else {
980b9175c69SKenjiro Tsuji p_error = parse_unsupported_format;
9817c478bd9Sstevel@tonic-gate }
9827c478bd9Sstevel@tonic-gate } else {
9837c478bd9Sstevel@tonic-gate if (IS_BIND_INFO(attrib_num)) {
984b9175c69SKenjiro Tsuji rc = add_bind_attribute(attrib_num, attr_val,
985b9175c69SKenjiro Tsuji len, proxy_info);
9867c478bd9Sstevel@tonic-gate } else if (IS_OPER_INFO(attrib_num)) {
987b9175c69SKenjiro Tsuji rc = add_operation_attribute(attrib_num,
988b9175c69SKenjiro Tsuji attr_val, len, nis_config, table_info);
9897c478bd9Sstevel@tonic-gate } else {
990b9175c69SKenjiro Tsuji rc = add_mapping_attribute(attrib_num, attr_val,
991b9175c69SKenjiro Tsuji len, table_mapping);
9927c478bd9Sstevel@tonic-gate }
9937c478bd9Sstevel@tonic-gate }
9947c478bd9Sstevel@tonic-gate if (p_error != no_parse_error) {
9957c478bd9Sstevel@tonic-gate report_error(attr_val, attr);
9967c478bd9Sstevel@tonic-gate error_reported = TRUE;
9977c478bd9Sstevel@tonic-gate break;
9987c478bd9Sstevel@tonic-gate }
9997c478bd9Sstevel@tonic-gate }
10007c478bd9Sstevel@tonic-gate ldap_value_free(vals);
10017c478bd9Sstevel@tonic-gate } else {
1002b9175c69SKenjiro Tsuji (void) ldap_get_option(ld,
1003b9175c69SKenjiro Tsuji LDAP_OPT_ERROR_NUMBER, &errnum);
10047c478bd9Sstevel@tonic-gate if (errnum != LDAP_SUCCESS)
10057c478bd9Sstevel@tonic-gate p_error = parse_ldap_get_values_error;
10067c478bd9Sstevel@tonic-gate }
10077c478bd9Sstevel@tonic-gate ldap_memfree(attr);
10087c478bd9Sstevel@tonic-gate if (p_error != no_parse_error)
10097c478bd9Sstevel@tonic-gate break;
10107c478bd9Sstevel@tonic-gate }
10117c478bd9Sstevel@tonic-gate } else {
10127c478bd9Sstevel@tonic-gate errnum = ldap_result2error(ld, resultMsg, FALSE);
10137c478bd9Sstevel@tonic-gate if (errnum != LDAP_SUCCESS)
10147c478bd9Sstevel@tonic-gate p_error = parse_ldap_search_error;
10157c478bd9Sstevel@tonic-gate }
10167c478bd9Sstevel@tonic-gate if (ber != NULL)
10177c478bd9Sstevel@tonic-gate ber_free(ber, 0);
10187c478bd9Sstevel@tonic-gate
10197c478bd9Sstevel@tonic-gate if (!error_reported && p_error != no_parse_error) {
10207c478bd9Sstevel@tonic-gate report_error(ldap_err2string(errnum), 0);
10217c478bd9Sstevel@tonic-gate }
10227c478bd9Sstevel@tonic-gate
10237c478bd9Sstevel@tonic-gate if (p_error != no_parse_error)
10247c478bd9Sstevel@tonic-gate rc = -1;
10257c478bd9Sstevel@tonic-gate return (rc);
10267c478bd9Sstevel@tonic-gate }
10277c478bd9Sstevel@tonic-gate
10287c478bd9Sstevel@tonic-gate /*
10297c478bd9Sstevel@tonic-gate * FUNCTION: process_ldap_referral
10307c478bd9Sstevel@tonic-gate *
10317c478bd9Sstevel@tonic-gate * Retrieves the configuration for a referral url
10327c478bd9Sstevel@tonic-gate *
10337c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure, 1 on skip
10347c478bd9Sstevel@tonic-gate *
10357c478bd9Sstevel@tonic-gate * INPUT: url the ldap url
10367c478bd9Sstevel@tonic-gate * __nis_ldap_proxy_info
10377c478bd9Sstevel@tonic-gate */
10387c478bd9Sstevel@tonic-gate
10397c478bd9Sstevel@tonic-gate static int
process_ldap_referral(char * url,char ** attrs,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)10407c478bd9Sstevel@tonic-gate process_ldap_referral(
10417c478bd9Sstevel@tonic-gate char *url,
10427c478bd9Sstevel@tonic-gate char **attrs,
10437c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
10447c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
10457c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
10467c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
10477c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
10487c478bd9Sstevel@tonic-gate {
10497c478bd9Sstevel@tonic-gate LDAPURLDesc *ludpp = NULL;
10507c478bd9Sstevel@tonic-gate int rc;
10517c478bd9Sstevel@tonic-gate LDAP *ld = NULL;
10527c478bd9Sstevel@tonic-gate int errnum;
10537c478bd9Sstevel@tonic-gate LDAPMessage *resultMsg = NULL;
10547c478bd9Sstevel@tonic-gate
10557c478bd9Sstevel@tonic-gate if ((rc = ldap_url_parse(url, &ludpp)) != LDAP_SUCCESS)
10567c478bd9Sstevel@tonic-gate return (1);
10577c478bd9Sstevel@tonic-gate
10587c478bd9Sstevel@tonic-gate #ifdef LDAP_URL_OPT_SECURE
10597c478bd9Sstevel@tonic-gate if (ludpp->lud_options & LDAP_URL_OPT_SECURE) {
10607c478bd9Sstevel@tonic-gate if (config_info->tls_method != ssl_tls) {
10617c478bd9Sstevel@tonic-gate ldap_free_urldesc(ludpp);
10627c478bd9Sstevel@tonic-gate return (1);
10637c478bd9Sstevel@tonic-gate }
10647c478bd9Sstevel@tonic-gate } else {
10657c478bd9Sstevel@tonic-gate if (config_info->tls_method != no_tls) {
10667c478bd9Sstevel@tonic-gate ldap_free_urldesc(ludpp);
10677c478bd9Sstevel@tonic-gate return (1);
10687c478bd9Sstevel@tonic-gate }
10697c478bd9Sstevel@tonic-gate }
10707c478bd9Sstevel@tonic-gate #endif
10717c478bd9Sstevel@tonic-gate
10727c478bd9Sstevel@tonic-gate if ((ld = connect_to_ldap_config_server(ludpp->lud_host,
10737c478bd9Sstevel@tonic-gate ludpp->lud_port, config_info)) == NULL) {
10747c478bd9Sstevel@tonic-gate ldap_free_urldesc(ludpp);
10757c478bd9Sstevel@tonic-gate return (-1);
10767c478bd9Sstevel@tonic-gate }
10777c478bd9Sstevel@tonic-gate
10787c478bd9Sstevel@tonic-gate errnum = ldap_search_s(ld, config_info->config_dn, LDAP_SCOPE_BASE,
10797c478bd9Sstevel@tonic-gate "objectclass=nisplusLDAPconfig", attrs, 0, &resultMsg);
10807c478bd9Sstevel@tonic-gate
10817c478bd9Sstevel@tonic-gate ldap_source = config_info->config_dn;
10827c478bd9Sstevel@tonic-gate
10837c478bd9Sstevel@tonic-gate if (errnum != LDAP_SUCCESS) {
10847c478bd9Sstevel@tonic-gate p_error = parse_ldap_search_error;
10857c478bd9Sstevel@tonic-gate report_error(ldap_err2string(errnum), 0);
10867c478bd9Sstevel@tonic-gate rc = -1;
10877c478bd9Sstevel@tonic-gate } else {
10887c478bd9Sstevel@tonic-gate rc = process_ldap_config_result(ld, resultMsg, proxy_info,
10897c478bd9Sstevel@tonic-gate nis_config, table_mapping, table_info);
10907c478bd9Sstevel@tonic-gate }
10917c478bd9Sstevel@tonic-gate
10927c478bd9Sstevel@tonic-gate ldap_source = NULL;
10937c478bd9Sstevel@tonic-gate (void) ldap_unbind(ld);
10947c478bd9Sstevel@tonic-gate if (resultMsg != NULL)
10957c478bd9Sstevel@tonic-gate (void) ldap_msgfree(resultMsg);
10967c478bd9Sstevel@tonic-gate
10977c478bd9Sstevel@tonic-gate return (rc);
10987c478bd9Sstevel@tonic-gate }
10997c478bd9Sstevel@tonic-gate
11007c478bd9Sstevel@tonic-gate /*
11017c478bd9Sstevel@tonic-gate * FUNCTION: process_ldap_referral_msg
11027c478bd9Sstevel@tonic-gate *
11037c478bd9Sstevel@tonic-gate * Retrieves the configuration from referred servers
11047c478bd9Sstevel@tonic-gate *
11057c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
11067c478bd9Sstevel@tonic-gate *
11077c478bd9Sstevel@tonic-gate * INPUT: LDAP the LDAP connection
11087c478bd9Sstevel@tonic-gate * LDAPMessage the LDAP message
11097c478bd9Sstevel@tonic-gate * __nis_ldap_proxy_info
11107c478bd9Sstevel@tonic-gate */
11117c478bd9Sstevel@tonic-gate
11127c478bd9Sstevel@tonic-gate static int
process_ldap_referral_msg(LDAP * ld,LDAPMessage * resultMsg,char ** attrs,__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)11137c478bd9Sstevel@tonic-gate process_ldap_referral_msg(
11147c478bd9Sstevel@tonic-gate LDAP *ld,
11157c478bd9Sstevel@tonic-gate LDAPMessage *resultMsg,
11167c478bd9Sstevel@tonic-gate char **attrs,
11177c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
11187c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
11197c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
11207c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
11217c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
11227c478bd9Sstevel@tonic-gate {
11237c478bd9Sstevel@tonic-gate int errCode;
11247c478bd9Sstevel@tonic-gate char **referralsp = NULL;
11257c478bd9Sstevel@tonic-gate int i;
11267c478bd9Sstevel@tonic-gate int rc;
11277c478bd9Sstevel@tonic-gate
11287c478bd9Sstevel@tonic-gate rc = ldap_parse_result(ld, resultMsg, &errCode, NULL, NULL, &referralsp,
11297c478bd9Sstevel@tonic-gate NULL, 0);
11307c478bd9Sstevel@tonic-gate
11317c478bd9Sstevel@tonic-gate if (rc != LDAP_SUCCESS || errCode != LDAP_REFERRAL) {
11327c478bd9Sstevel@tonic-gate p_error = parse_ldap_get_values_error;
11337c478bd9Sstevel@tonic-gate report_error(ldap_err2string(errCode), 0);
11347c478bd9Sstevel@tonic-gate rc = -1;
11357c478bd9Sstevel@tonic-gate } else {
11367c478bd9Sstevel@tonic-gate for (i = 0; referralsp[i] != NULL; i++) {
11377c478bd9Sstevel@tonic-gate rc = process_ldap_referral(referralsp[i], attrs,
11387c478bd9Sstevel@tonic-gate proxy_info, nis_config, table_mapping,
11397c478bd9Sstevel@tonic-gate config_info, table_info);
11407c478bd9Sstevel@tonic-gate if (rc <= 0)
11417c478bd9Sstevel@tonic-gate break;
11427c478bd9Sstevel@tonic-gate else
11437c478bd9Sstevel@tonic-gate report_info("Cannot use referral \n",
11447c478bd9Sstevel@tonic-gate referralsp[i]);
11457c478bd9Sstevel@tonic-gate
11467c478bd9Sstevel@tonic-gate }
11477c478bd9Sstevel@tonic-gate if (rc > 0) {
11487c478bd9Sstevel@tonic-gate p_error = parse_no_available_referrals_error;
11497c478bd9Sstevel@tonic-gate report_error(0, 0);
11507c478bd9Sstevel@tonic-gate }
11517c478bd9Sstevel@tonic-gate }
11527c478bd9Sstevel@tonic-gate
11537c478bd9Sstevel@tonic-gate if (referralsp)
11547c478bd9Sstevel@tonic-gate ldap_value_free(referralsp);
11557c478bd9Sstevel@tonic-gate
11567c478bd9Sstevel@tonic-gate return (rc);
11577c478bd9Sstevel@tonic-gate }
11587c478bd9Sstevel@tonic-gate
11597c478bd9Sstevel@tonic-gate /*
11607c478bd9Sstevel@tonic-gate * FUNCTION: parse_ldap_config_dn_attrs
11617c478bd9Sstevel@tonic-gate *
11627c478bd9Sstevel@tonic-gate * Parses the information for LDAP from the LDAP profile
11637c478bd9Sstevel@tonic-gate * - the profile object name, the LDAP server, and the
11647c478bd9Sstevel@tonic-gate * authentication method must be specified.
11657c478bd9Sstevel@tonic-gate *
11667c478bd9Sstevel@tonic-gate * RETURN VALUE: 0 on success, -1 on failure
11677c478bd9Sstevel@tonic-gate *
11687c478bd9Sstevel@tonic-gate * INPUT: __nis_ldap_proxy_info
11697c478bd9Sstevel@tonic-gate */
11707c478bd9Sstevel@tonic-gate
11717c478bd9Sstevel@tonic-gate static int
parse_ldap_config_dn_attrs(__nis_ldap_proxy_info * proxy_info,__nis_config_t * nis_config,__nis_table_mapping_t ** table_mapping,__nis_config_info_t * config_info,__nisdb_table_mapping_t * table_info)11727c478bd9Sstevel@tonic-gate parse_ldap_config_dn_attrs(
11737c478bd9Sstevel@tonic-gate __nis_ldap_proxy_info *proxy_info,
11747c478bd9Sstevel@tonic-gate __nis_config_t *nis_config,
11757c478bd9Sstevel@tonic-gate __nis_table_mapping_t **table_mapping,
11767c478bd9Sstevel@tonic-gate __nis_config_info_t *config_info,
11777c478bd9Sstevel@tonic-gate __nisdb_table_mapping_t *table_info)
11787c478bd9Sstevel@tonic-gate {
11797c478bd9Sstevel@tonic-gate int rc = 0;
11807c478bd9Sstevel@tonic-gate LDAP *ld = NULL;
11817c478bd9Sstevel@tonic-gate int errnum;
11827c478bd9Sstevel@tonic-gate char *ldap_config_attributes[n_config_keys];
11837c478bd9Sstevel@tonic-gate LDAPMessage *resultMsg = NULL;
11847c478bd9Sstevel@tonic-gate
11857c478bd9Sstevel@tonic-gate /* Determine if properly configured for LDAP lookup */
11867c478bd9Sstevel@tonic-gate if (config_info->auth_method == simple &&
11877c478bd9Sstevel@tonic-gate config_info->proxy_dn == NULL)
11887c478bd9Sstevel@tonic-gate p_error = parse_no_proxy_dn_error;
11897c478bd9Sstevel@tonic-gate else if (config_info->auth_method ==
11907c478bd9Sstevel@tonic-gate (auth_method_t)NO_VALUE_SET)
11917c478bd9Sstevel@tonic-gate p_error = parse_no_config_auth_error;
11927c478bd9Sstevel@tonic-gate else if ((config_info->default_servers == NULL) ||
11937c478bd9Sstevel@tonic-gate (config_info->default_servers[0] == '\0'))
11947c478bd9Sstevel@tonic-gate p_error = parse_no_config_server_addr;
11957c478bd9Sstevel@tonic-gate if (p_error != no_parse_error) {
11967c478bd9Sstevel@tonic-gate report_error(NULL, NULL);
11977c478bd9Sstevel@tonic-gate return (-1);
11987c478bd9Sstevel@tonic-gate }
11997c478bd9Sstevel@tonic-gate
12007c478bd9Sstevel@tonic-gate if (config_info->tls_method == (tls_method_t)NO_VALUE_SET)
12017c478bd9Sstevel@tonic-gate config_info->tls_method = no_tls;
12027c478bd9Sstevel@tonic-gate else if (config_info->tls_method == ssl_tls &&
12037c478bd9Sstevel@tonic-gate (config_info->tls_cert_db == NULL ||
12047c478bd9Sstevel@tonic-gate *config_info->tls_cert_db == '\0')) {
12057c478bd9Sstevel@tonic-gate p_error = parse_no_config_cert_db;
12067c478bd9Sstevel@tonic-gate report_error(NULL, NULL);
12077c478bd9Sstevel@tonic-gate return (-1);
12087c478bd9Sstevel@tonic-gate }
12097c478bd9Sstevel@tonic-gate
12107c478bd9Sstevel@tonic-gate if (verbose)
12117c478bd9Sstevel@tonic-gate report_info(
12127c478bd9Sstevel@tonic-gate "Getting configuration from LDAP server(s): ",
12137c478bd9Sstevel@tonic-gate config_info->default_servers);
12147c478bd9Sstevel@tonic-gate
12157c478bd9Sstevel@tonic-gate /* Determine which attributes should be retrieved */
12167c478bd9Sstevel@tonic-gate get_attribute_list(proxy_info, nis_config, NULL, table_info,
12177c478bd9Sstevel@tonic-gate ldap_config_attributes);
12187c478bd9Sstevel@tonic-gate
12197c478bd9Sstevel@tonic-gate if ((ld = connect_to_ldap_config_server(config_info->default_servers, 0,
12207c478bd9Sstevel@tonic-gate config_info)) == NULL)
12217c478bd9Sstevel@tonic-gate return (-1);
12227c478bd9Sstevel@tonic-gate
12237c478bd9Sstevel@tonic-gate /* Get the attribute values */
12247c478bd9Sstevel@tonic-gate errnum = ldap_search_s(ld, config_info->config_dn, LDAP_SCOPE_BASE,
12257c478bd9Sstevel@tonic-gate "objectclass=nisplusLDAPconfig",
12267c478bd9Sstevel@tonic-gate ldap_config_attributes, 0, &resultMsg);
12277c478bd9Sstevel@tonic-gate ldap_source = config_info->config_dn;
12287c478bd9Sstevel@tonic-gate
12297c478bd9Sstevel@tonic-gate if (errnum == LDAP_REFERRAL) {
12307c478bd9Sstevel@tonic-gate rc = process_ldap_referral_msg(ld, resultMsg,
12317c478bd9Sstevel@tonic-gate ldap_config_attributes, proxy_info, nis_config,
12327c478bd9Sstevel@tonic-gate table_mapping, config_info, table_info);
12337c478bd9Sstevel@tonic-gate } else if (errnum != LDAP_SUCCESS) {
12347c478bd9Sstevel@tonic-gate p_error = parse_ldap_search_error;
12357c478bd9Sstevel@tonic-gate report_error(ldap_err2string(errnum), 0);
12367c478bd9Sstevel@tonic-gate rc = -1;
12377c478bd9Sstevel@tonic-gate } else {
12387c478bd9Sstevel@tonic-gate rc = process_ldap_config_result(ld, resultMsg, proxy_info,
12397c478bd9Sstevel@tonic-gate nis_config, table_mapping, table_info);
12407c478bd9Sstevel@tonic-gate }
12417c478bd9Sstevel@tonic-gate
12427c478bd9Sstevel@tonic-gate ldap_source = NULL;
12437c478bd9Sstevel@tonic-gate (void) ldap_unbind(ld);
12447c478bd9Sstevel@tonic-gate if (resultMsg != NULL)
12457c478bd9Sstevel@tonic-gate (void) ldap_msgfree(resultMsg);
12467c478bd9Sstevel@tonic-gate
12477c478bd9Sstevel@tonic-gate return (rc);
12487c478bd9Sstevel@tonic-gate }
12497c478bd9Sstevel@tonic-gate
12507c478bd9Sstevel@tonic-gate bool_t
is_cmd_line_option(config_key a_num)12517c478bd9Sstevel@tonic-gate is_cmd_line_option(config_key a_num)
12527c478bd9Sstevel@tonic-gate {
12537c478bd9Sstevel@tonic-gate const char *const *cmdline_options = cmdline_config;
12547c478bd9Sstevel@tonic-gate config_key attrib_num;
12557c478bd9Sstevel@tonic-gate const char *begin_s;
12567c478bd9Sstevel@tonic-gate const char *end_s;
12577c478bd9Sstevel@tonic-gate
12587c478bd9Sstevel@tonic-gate if (cmdline_options == NULL)
12597c478bd9Sstevel@tonic-gate return (FALSE);
12607c478bd9Sstevel@tonic-gate
12617c478bd9Sstevel@tonic-gate while (*cmdline_options != NULL) {
12627c478bd9Sstevel@tonic-gate attrib_num = get_attrib_num_cmdline(
12637c478bd9Sstevel@tonic-gate *cmdline_options, &begin_s, &end_s);
12647c478bd9Sstevel@tonic-gate if (attrib_num == a_num)
12657c478bd9Sstevel@tonic-gate break;
12667c478bd9Sstevel@tonic-gate cmdline_options++;
12677c478bd9Sstevel@tonic-gate }
12687c478bd9Sstevel@tonic-gate return (*cmdline_options != NULL);
12697c478bd9Sstevel@tonic-gate }
12707c478bd9Sstevel@tonic-gate
12717c478bd9Sstevel@tonic-gate /*
12727c478bd9Sstevel@tonic-gate * FUNCTION: get_attribute_list
12737c478bd9Sstevel@tonic-gate *
12747c478bd9Sstevel@tonic-gate * Get a list of attributes from the LDAP server that have not yet
12757c478bd9Sstevel@tonic-gate * been gotten. If config_info is NULL, the associated parameters
12767c478bd9Sstevel@tonic-gate * are not needed.
12777c478bd9Sstevel@tonic-gate *
12787c478bd9Sstevel@tonic-gate * RETURN VALUE: none
12797c478bd9Sstevel@tonic-gate *
12807c478bd9Sstevel@tonic-gate * INPUT: Returns a list of parameters in attributes
12817c478bd9Sstevel@tonic-gate * which is assumed to be of sufficient size.
12827c478bd9Sstevel@tonic-gate */
12837c478bd9Sstevel@tonic-gate
12847c478bd9Sstevel@tonic-gate static void
get_attribute_list(const __nis_ldap_proxy_info * proxy_info,const __nis_config_t * nis_config,const __nis_config_info_t * config_info,const __nisdb_table_mapping_t * table_info,char ** attributes)12857c478bd9Sstevel@tonic-gate get_attribute_list(
12867c478bd9Sstevel@tonic-gate const __nis_ldap_proxy_info *proxy_info,
12877c478bd9Sstevel@tonic-gate const __nis_config_t *nis_config,
12887c478bd9Sstevel@tonic-gate const __nis_config_info_t *config_info,
12897c478bd9Sstevel@tonic-gate const __nisdb_table_mapping_t *table_info,
12907c478bd9Sstevel@tonic-gate char **attributes)
12917c478bd9Sstevel@tonic-gate {
12927c478bd9Sstevel@tonic-gate int n_attrs;
12937c478bd9Sstevel@tonic-gate
12947c478bd9Sstevel@tonic-gate /* Determine which attributes should be retrieved */
12957c478bd9Sstevel@tonic-gate n_attrs = 0;
12967c478bd9Sstevel@tonic-gate
12977c478bd9Sstevel@tonic-gate if (config_info != NULL) {
12987c478bd9Sstevel@tonic-gate if (yp2ldap) {
12997c478bd9Sstevel@tonic-gate if (config_info->config_dn == NULL)
13007c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_DN;
13017c478bd9Sstevel@tonic-gate if (config_info->default_servers == NULL)
13027c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_SERVER_LIST;
13037c478bd9Sstevel@tonic-gate if (config_info->auth_method ==
13047c478bd9Sstevel@tonic-gate (auth_method_t)NO_VALUE_SET)
13057c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_AUTH_METHOD;
13067c478bd9Sstevel@tonic-gate if (config_info->tls_method ==
13077c478bd9Sstevel@tonic-gate (tls_method_t)NO_VALUE_SET)
13087c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_TLS_OPTION;
13097c478bd9Sstevel@tonic-gate if (config_info->proxy_dn == NULL)
13107c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_PROXY_USER;
13117c478bd9Sstevel@tonic-gate if (config_info->proxy_passwd == NULL)
13127c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_PROXY_PASSWD;
13137c478bd9Sstevel@tonic-gate if (config_info->tls_cert_db == NULL)
13147c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_CONFIG_TLS_CERT_DB;
13157c478bd9Sstevel@tonic-gate } else {
13167c478bd9Sstevel@tonic-gate if (config_info->config_dn == NULL)
13177c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_DN;
13187c478bd9Sstevel@tonic-gate if (config_info->default_servers == NULL)
13197c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_SERVER_LIST;
13207c478bd9Sstevel@tonic-gate if (config_info->auth_method ==
13217c478bd9Sstevel@tonic-gate (auth_method_t)NO_VALUE_SET)
13227c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_AUTH_METHOD;
13237c478bd9Sstevel@tonic-gate if (config_info->tls_method ==
13247c478bd9Sstevel@tonic-gate (tls_method_t)NO_VALUE_SET)
13257c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_TLS_OPTION;
13267c478bd9Sstevel@tonic-gate if (config_info->proxy_dn == NULL)
13277c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_PROXY_USER;
13287c478bd9Sstevel@tonic-gate if (config_info->proxy_passwd == NULL)
13297c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_PROXY_PASSWD;
13307c478bd9Sstevel@tonic-gate if (config_info->tls_cert_db == NULL)
13317c478bd9Sstevel@tonic-gate attributes[n_attrs++] = CONFIG_TLS_CERT_DB;
13327c478bd9Sstevel@tonic-gate }
13337c478bd9Sstevel@tonic-gate } else {
13347c478bd9Sstevel@tonic-gate if (yp2ldap) {
13357c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_DOMAIN_CONTEXT;
13367c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YPPASSWDD_DOMAINS;
13377c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_DB_ID_MAP;
13387c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_COMMENT_CHAR;
13397c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_MAP_FLAGS;
13407c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_ENTRY_TTL;
13417c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_NAME_FIELDS;
13427c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_SPLIT_FIELD;
13437c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_REPEATED_FIELD_SEPARATORS;
13447c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_LDAP_OBJECT_DN;
13457c478bd9Sstevel@tonic-gate attributes[n_attrs++] = NIS_TO_LDAP_MAP;
13467c478bd9Sstevel@tonic-gate attributes[n_attrs++] = LDAP_TO_NIS_MAP;
13477c478bd9Sstevel@tonic-gate } else {
13487c478bd9Sstevel@tonic-gate attributes[n_attrs++] = DB_ID_MAP;
13497c478bd9Sstevel@tonic-gate attributes[n_attrs++] = ENTRY_TTL;
13507c478bd9Sstevel@tonic-gate attributes[n_attrs++] = LDAP_OBJECT_DN;
13517c478bd9Sstevel@tonic-gate attributes[n_attrs++] = NISPLUS_TO_LDAP_MAP;
13527c478bd9Sstevel@tonic-gate attributes[n_attrs++] = LDAP_TO_NISPLUS_MAP;
13537c478bd9Sstevel@tonic-gate }
13547c478bd9Sstevel@tonic-gate }
13557c478bd9Sstevel@tonic-gate
13567c478bd9Sstevel@tonic-gate if (yp2ldap) {
13577c478bd9Sstevel@tonic-gate if (proxy_info->default_servers == NULL)
13587c478bd9Sstevel@tonic-gate attributes[n_attrs++] = PREFERRED_SERVERS;
13597c478bd9Sstevel@tonic-gate if (proxy_info->auth_method == (auth_method_t)NO_VALUE_SET)
13607c478bd9Sstevel@tonic-gate attributes[n_attrs++] = AUTH_METHOD;
13617c478bd9Sstevel@tonic-gate if (proxy_info->tls_method == (tls_method_t)NO_VALUE_SET)
13627c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_TLS_OPTION;
13637c478bd9Sstevel@tonic-gate if (proxy_info->tls_cert_db == NULL)
13647c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_TLS_CERT_DB;
13657c478bd9Sstevel@tonic-gate if (proxy_info->default_search_base == NULL)
13667c478bd9Sstevel@tonic-gate attributes[n_attrs++] = SEARCH_BASE;
13677c478bd9Sstevel@tonic-gate if (proxy_info->proxy_dn == NULL)
13687c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_PROXY_USER;
13697c478bd9Sstevel@tonic-gate if (proxy_info->proxy_passwd == NULL)
13707c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_PROXY_PASSWD;
13717c478bd9Sstevel@tonic-gate if (proxy_info->default_nis_domain == NULL)
13727c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_LDAP_BASE_DOMAIN;
13737c478bd9Sstevel@tonic-gate if (proxy_info->bind_timeout.tv_sec ==
13747c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
13757c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_BIND_TIMEOUT;
13767c478bd9Sstevel@tonic-gate if (proxy_info->search_timeout.tv_sec ==
13777c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
13787c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_SEARCH_TIMEOUT;
13797c478bd9Sstevel@tonic-gate if (proxy_info->modify_timeout.tv_sec ==
13807c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
13817c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_MODIFY_TIMEOUT;
13827c478bd9Sstevel@tonic-gate if (proxy_info->add_timeout.tv_sec == (time_t)NO_VALUE_SET)
13837c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_ADD_TIMEOUT;
13847c478bd9Sstevel@tonic-gate if (proxy_info->delete_timeout.tv_sec ==
13857c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
13867c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_DELETE_TIMEOUT;
13877c478bd9Sstevel@tonic-gate if (proxy_info->search_time_limit == (int)NO_VALUE_SET)
13887c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_SEARCH_TIME_LIMIT;
13897c478bd9Sstevel@tonic-gate if (proxy_info->search_size_limit == (int)NO_VALUE_SET)
13907c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_SEARCH_SIZE_LIMIT;
13917c478bd9Sstevel@tonic-gate if (proxy_info->follow_referral ==
13927c478bd9Sstevel@tonic-gate (follow_referral_t)NO_VALUE_SET)
13937c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_FOLLOW_REFERRAL;
13947c478bd9Sstevel@tonic-gate
13957c478bd9Sstevel@tonic-gate if (table_info->retrieveError ==
13967c478bd9Sstevel@tonic-gate (__nis_retrieve_error_t)NO_VALUE_SET)
13977c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_RETRIEVE_ERROR_ACTION;
13987c478bd9Sstevel@tonic-gate if (table_info->retrieveErrorRetry.attempts == NO_VALUE_SET)
13997c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_RETREIVE_ERROR_ATTEMPTS;
14007c478bd9Sstevel@tonic-gate if (table_info->retrieveErrorRetry.timeout ==
14017c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14027c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_RETREIVE_ERROR_TIMEOUT;
14037c478bd9Sstevel@tonic-gate if (table_info->storeError ==
14047c478bd9Sstevel@tonic-gate (__nis_store_error_t)NO_VALUE_SET)
14057c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_STORE_ERROR_ACTION;
14067c478bd9Sstevel@tonic-gate if (table_info->storeErrorRetry.attempts == NO_VALUE_SET)
14077c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_STORE_ERROR_ATTEMPTS;
14087c478bd9Sstevel@tonic-gate if (table_info->storeErrorRetry.timeout ==
14097c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14107c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_STORE_ERROR_TIMEOUT;
14117c478bd9Sstevel@tonic-gate if (table_info->refreshError ==
14127c478bd9Sstevel@tonic-gate (__nis_refresh_error_t)NO_VALUE_SET)
14137c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_ACTION;
14147c478bd9Sstevel@tonic-gate if (table_info->refreshErrorRetry.attempts == NO_VALUE_SET)
14157c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_ATTEMPTS;
14167c478bd9Sstevel@tonic-gate if (table_info->refreshErrorRetry.timeout ==
14177c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14187c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_TIMEOUT;
14197c478bd9Sstevel@tonic-gate if (table_info->matchFetch ==
14207c478bd9Sstevel@tonic-gate (__nis_match_fetch_t)NO_VALUE_SET)
14217c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_MATCH_FETCH;
14227c478bd9Sstevel@tonic-gate } else {
14237c478bd9Sstevel@tonic-gate if (proxy_info->default_servers == NULL)
14247c478bd9Sstevel@tonic-gate attributes[n_attrs++] = PREFERRED_SERVERS;
14257c478bd9Sstevel@tonic-gate if (proxy_info->auth_method == (auth_method_t)NO_VALUE_SET)
14267c478bd9Sstevel@tonic-gate attributes[n_attrs++] = AUTH_METHOD;
14277c478bd9Sstevel@tonic-gate if (proxy_info->tls_method == (tls_method_t)NO_VALUE_SET)
14287c478bd9Sstevel@tonic-gate attributes[n_attrs++] = TLS_OPTION;
14297c478bd9Sstevel@tonic-gate if (proxy_info->tls_cert_db == NULL)
14307c478bd9Sstevel@tonic-gate attributes[n_attrs++] = TLS_CERT_DB;
14317c478bd9Sstevel@tonic-gate if (proxy_info->default_search_base == NULL)
14327c478bd9Sstevel@tonic-gate attributes[n_attrs++] = SEARCH_BASE;
14337c478bd9Sstevel@tonic-gate if (proxy_info->proxy_dn == NULL)
14347c478bd9Sstevel@tonic-gate attributes[n_attrs++] = PROXY_USER;
14357c478bd9Sstevel@tonic-gate if (proxy_info->proxy_passwd == NULL)
14367c478bd9Sstevel@tonic-gate attributes[n_attrs++] = PROXY_PASSWD;
14377c478bd9Sstevel@tonic-gate if (proxy_info->default_nis_domain == NULL)
14387c478bd9Sstevel@tonic-gate attributes[n_attrs++] = LDAP_BASE_DOMAIN;
14397c478bd9Sstevel@tonic-gate if (proxy_info->bind_timeout.tv_sec ==
14407c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14417c478bd9Sstevel@tonic-gate attributes[n_attrs++] = BIND_TIMEOUT;
14427c478bd9Sstevel@tonic-gate if (proxy_info->search_timeout.tv_sec ==
14437c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14447c478bd9Sstevel@tonic-gate attributes[n_attrs++] = SEARCH_TIMEOUT;
14457c478bd9Sstevel@tonic-gate if (proxy_info->modify_timeout.tv_sec ==
14467c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14477c478bd9Sstevel@tonic-gate attributes[n_attrs++] = MODIFY_TIMEOUT;
14487c478bd9Sstevel@tonic-gate if (proxy_info->add_timeout.tv_sec == (time_t)NO_VALUE_SET)
14497c478bd9Sstevel@tonic-gate attributes[n_attrs++] = ADD_TIMEOUT;
14507c478bd9Sstevel@tonic-gate if (proxy_info->delete_timeout.tv_sec ==
14517c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14527c478bd9Sstevel@tonic-gate attributes[n_attrs++] = DELETE_TIMEOUT;
14537c478bd9Sstevel@tonic-gate if (proxy_info->search_time_limit == (int)NO_VALUE_SET)
14547c478bd9Sstevel@tonic-gate attributes[n_attrs++] = SEARCH_TIME_LIMIT;
14557c478bd9Sstevel@tonic-gate if (proxy_info->search_size_limit == (int)NO_VALUE_SET)
14567c478bd9Sstevel@tonic-gate attributes[n_attrs++] = SEARCH_SIZE_LIMIT;
14577c478bd9Sstevel@tonic-gate if (proxy_info->follow_referral ==
14587c478bd9Sstevel@tonic-gate (follow_referral_t)NO_VALUE_SET)
14597c478bd9Sstevel@tonic-gate attributes[n_attrs++] = FOLLOW_REFERRAL;
14607c478bd9Sstevel@tonic-gate
14617c478bd9Sstevel@tonic-gate if (table_info->retrieveError ==
14627c478bd9Sstevel@tonic-gate (__nis_retrieve_error_t)NO_VALUE_SET)
14637c478bd9Sstevel@tonic-gate attributes[n_attrs++] = RETRIEVE_ERROR_ACTION;
14647c478bd9Sstevel@tonic-gate if (table_info->retrieveErrorRetry.attempts == NO_VALUE_SET)
14657c478bd9Sstevel@tonic-gate attributes[n_attrs++] = RETREIVE_ERROR_ATTEMPTS;
14667c478bd9Sstevel@tonic-gate if (table_info->retrieveErrorRetry.timeout ==
14677c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14687c478bd9Sstevel@tonic-gate attributes[n_attrs++] = RETREIVE_ERROR_TIMEOUT;
14697c478bd9Sstevel@tonic-gate if (table_info->storeError ==
14707c478bd9Sstevel@tonic-gate (__nis_store_error_t)NO_VALUE_SET)
14717c478bd9Sstevel@tonic-gate attributes[n_attrs++] = STORE_ERROR_ACTION;
14727c478bd9Sstevel@tonic-gate if (table_info->storeErrorRetry.attempts == NO_VALUE_SET)
14737c478bd9Sstevel@tonic-gate attributes[n_attrs++] = STORE_ERROR_ATTEMPTS;
14747c478bd9Sstevel@tonic-gate if (table_info->storeErrorRetry.timeout ==
14757c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14767c478bd9Sstevel@tonic-gate attributes[n_attrs++] = STORE_ERROR_TIMEOUT;
14777c478bd9Sstevel@tonic-gate if (table_info->refreshError ==
14787c478bd9Sstevel@tonic-gate (__nis_refresh_error_t)NO_VALUE_SET)
14797c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_ACTION;
14807c478bd9Sstevel@tonic-gate if (table_info->refreshErrorRetry.attempts == NO_VALUE_SET)
14817c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_ATTEMPTS;
14827c478bd9Sstevel@tonic-gate if (table_info->refreshErrorRetry.timeout ==
14837c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
14847c478bd9Sstevel@tonic-gate attributes[n_attrs++] = REFRESH_ERROR_TIMEOUT;
14857c478bd9Sstevel@tonic-gate if (table_info->matchFetch ==
14867c478bd9Sstevel@tonic-gate (__nis_match_fetch_t)NO_VALUE_SET)
14877c478bd9Sstevel@tonic-gate attributes[n_attrs++] = MATCH_FETCH;
14887c478bd9Sstevel@tonic-gate }
14897c478bd9Sstevel@tonic-gate
14907c478bd9Sstevel@tonic-gate switch (nis_config->initialUpdate) {
14917c478bd9Sstevel@tonic-gate case (__nis_initial_update_t)NO_VALUE_SET:
14927c478bd9Sstevel@tonic-gate attributes[n_attrs++] = INITIAL_UPDATE_ACTION;
14937c478bd9Sstevel@tonic-gate attributes[n_attrs++] = INITIAL_UPDATE_ONLY;
14947c478bd9Sstevel@tonic-gate break;
14957c478bd9Sstevel@tonic-gate case (__nis_initial_update_t)INITIAL_UPDATE_NO_ACTION:
14967c478bd9Sstevel@tonic-gate case (__nis_initial_update_t)NO_INITIAL_UPDATE_NO_ACTION:
14977c478bd9Sstevel@tonic-gate attributes[n_attrs++] = INITIAL_UPDATE_ACTION;
14987c478bd9Sstevel@tonic-gate break;
14997c478bd9Sstevel@tonic-gate case (__nis_initial_update_t)FROM_NO_INITIAL_UPDATE:
15007c478bd9Sstevel@tonic-gate case (__nis_initial_update_t)TO_NO_INITIAL_UPDATE:
15017c478bd9Sstevel@tonic-gate attributes[n_attrs++] = INITIAL_UPDATE_ONLY;
15027c478bd9Sstevel@tonic-gate break;
15037c478bd9Sstevel@tonic-gate }
15047c478bd9Sstevel@tonic-gate
15057c478bd9Sstevel@tonic-gate if (nis_config->threadCreationError ==
15067c478bd9Sstevel@tonic-gate (__nis_thread_creation_error_t)NO_VALUE_SET)
15077c478bd9Sstevel@tonic-gate attributes[n_attrs++] = THREAD_CREATE_ERROR_ACTION;
15087c478bd9Sstevel@tonic-gate if (nis_config->threadCreationErrorTimeout.attempts == NO_VALUE_SET)
15097c478bd9Sstevel@tonic-gate attributes[n_attrs++] = THREAD_CREATE_ERROR_ATTEMPTS;
15107c478bd9Sstevel@tonic-gate if (nis_config->threadCreationErrorTimeout.timeout ==
15117c478bd9Sstevel@tonic-gate (time_t)NO_VALUE_SET)
15127c478bd9Sstevel@tonic-gate attributes[n_attrs++] = THREAD_CREATE_ERROR_TIMEOUT;
15137c478bd9Sstevel@tonic-gate if (nis_config->dumpError == (__nis_dump_error_t)NO_VALUE_SET)
15147c478bd9Sstevel@tonic-gate attributes[n_attrs++] = DUMP_ERROR_ACTION;
15157c478bd9Sstevel@tonic-gate if (nis_config->dumpErrorTimeout.attempts == NO_VALUE_SET)
15167c478bd9Sstevel@tonic-gate attributes[n_attrs++] = DUMP_ERROR_ATTEMPTS;
15177c478bd9Sstevel@tonic-gate if (nis_config->dumpErrorTimeout.timeout == (time_t)NO_VALUE_SET)
15187c478bd9Sstevel@tonic-gate attributes[n_attrs++] = DUMP_ERROR_TIMEOUT;
15197c478bd9Sstevel@tonic-gate if (nis_config->resyncService == (__nis_resync_service_t)NO_VALUE_SET)
15207c478bd9Sstevel@tonic-gate attributes[n_attrs++] = RESYNC;
15217c478bd9Sstevel@tonic-gate if (nis_config->updateBatching ==
15227c478bd9Sstevel@tonic-gate (__nis_update_batching_t)NO_VALUE_SET)
15237c478bd9Sstevel@tonic-gate attributes[n_attrs++] = UPDATE_BATCHING;
15247c478bd9Sstevel@tonic-gate if (nis_config->updateBatchingTimeout.timeout == (time_t)NO_VALUE_SET)
15257c478bd9Sstevel@tonic-gate attributes[n_attrs++] = UPDATE_BATCHING_TIMEOUT;
15267c478bd9Sstevel@tonic-gate if (nis_config->numberOfServiceThreads == (int)NO_VALUE_SET)
15277c478bd9Sstevel@tonic-gate attributes[n_attrs++] = NUMBER_THEADS;
15287c478bd9Sstevel@tonic-gate if (nis_config->emulate_yp == (int)NO_VALUE_SET)
15297c478bd9Sstevel@tonic-gate attributes[n_attrs++] = YP_EMULATION;
15307c478bd9Sstevel@tonic-gate
15317c478bd9Sstevel@tonic-gate /* maxRPCRecordSize is not configurable through LDAP profiles */
15327c478bd9Sstevel@tonic-gate if (nis_config->maxRPCRecordSize == (int)NO_VALUE_SET)
15337c478bd9Sstevel@tonic-gate attributes[n_attrs++] = MAX_RPC_RECSIZE;
15347c478bd9Sstevel@tonic-gate
15357c478bd9Sstevel@tonic-gate attributes[n_attrs++] = NULL;
15367c478bd9Sstevel@tonic-gate }
15377c478bd9Sstevel@tonic-gate
15387c478bd9Sstevel@tonic-gate /*
15397c478bd9Sstevel@tonic-gate * Notes on adding new attributes
15407c478bd9Sstevel@tonic-gate * 1. Determine where the attribute value will be saved
15417c478bd9Sstevel@tonic-gate * Currently, the following structures are defined:
15427c478bd9Sstevel@tonic-gate * __nis_config_info_t config_info
15437c478bd9Sstevel@tonic-gate * __nis_ldap_proxy_info proxyInfo
15447c478bd9Sstevel@tonic-gate * __nis_config_t ldapConfig
15457c478bd9Sstevel@tonic-gate * __nisdb_table_mapping_t ldapDBTableMapping
15467c478bd9Sstevel@tonic-gate * __nis_table_mapping_t ldapTableMapping
15477c478bd9Sstevel@tonic-gate * or add a new structure or variable - this will require
15487c478bd9Sstevel@tonic-gate * more code.
15497c478bd9Sstevel@tonic-gate * 2. Initialize the value to a known unconfigured value.
15507c478bd9Sstevel@tonic-gate * This can be done in initialize_parse_structs or
15517c478bd9Sstevel@tonic-gate * parse_ldap_migration.
15527c478bd9Sstevel@tonic-gate * 3. In the header file nis_parse_ldap_conf.h, add the name
15537c478bd9Sstevel@tonic-gate * of the attribute. (Currently, the attribute name is assumed
15547c478bd9Sstevel@tonic-gate * to be the same for the command line, the preference file,
15557c478bd9Sstevel@tonic-gate * and LDAP.) The names are grouped logically. Add a corresponding
15567c478bd9Sstevel@tonic-gate * config_key to the enum. Note that position in this file is
15577c478bd9Sstevel@tonic-gate * essential because the macros such as IS_BIND_INFO depend on
15587c478bd9Sstevel@tonic-gate * the sequence. The corresponding macro (IS_CONFIG_KEYWORD,
15597c478bd9Sstevel@tonic-gate * IS_BIND_INFO, or IS_OPER_INFO) may need to be adjusted. These
15607c478bd9Sstevel@tonic-gate * are used to partition the attributes into smaller chunks.
15617c478bd9Sstevel@tonic-gate * 4. Add the correspond entry to the keyword_lookup array in
15627c478bd9Sstevel@tonic-gate * nis_parse_ldap_attr.c, which is used to determine the config_key
15637c478bd9Sstevel@tonic-gate * from the corresponding key word.
15647c478bd9Sstevel@tonic-gate * 5. Add the attribute to the list of attributes to retrieve from
15657c478bd9Sstevel@tonic-gate * the LDAP server if no value has been set in the function
15667c478bd9Sstevel@tonic-gate * parse_ldap_config_dn_attrs. (This assumes that the attribute
15677c478bd9Sstevel@tonic-gate * is not used to get the configuration from the LDAP server.)
15687c478bd9Sstevel@tonic-gate * 6. Add logic to parse the individual attribute in
15697c478bd9Sstevel@tonic-gate * add_config_attribute, add_bind_attribute,
15707c478bd9Sstevel@tonic-gate * add_operation_attribute, or add_mapping_attribute depending
15717c478bd9Sstevel@tonic-gate * which group of attributes the added attribute belongs to.
15727c478bd9Sstevel@tonic-gate * 7. In set_default_values, if the attribute value has not been set, set
15737c478bd9Sstevel@tonic-gate * the default value. If any additional fixup is needed depending
15747c478bd9Sstevel@tonic-gate * on other configuration values, it should be done here.
15757c478bd9Sstevel@tonic-gate * 8. If an attribute name is a subset of another, parse_ldap_default_conf
15767c478bd9Sstevel@tonic-gate * should be modified.
15777c478bd9Sstevel@tonic-gate */
1578