4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2015 Gary Mills
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
42 #include "ldap_parse.h"
43 #include "ldap_glob.h"
44 #include "nis_parse_ldap_conf.h"
46 __nis_ldap_proxy_info proxyInfo
=
47 {NULL
, (auth_method_t
)NO_VALUE_SET
, (tls_method_t
)NO_VALUE_SET
, NULL
,
48 NULL
, NULL
, NULL
, NULL
, (follow_referral_t
)NO_VALUE_SET
};
49 __nis_config_t ldapConfig
;
50 __nisdb_table_mapping_t ldapDBTableMapping
;
51 __nis_table_mapping_t
*ldapTableMapping
= NULL
;
52 __yp_domain_context_t ypDomains
;
54 parse_error p_error
= no_parse_error
;
56 int start_line_num
= 0;
58 const char *warn_file
= NULL
;
61 const char *command_line_source
= NULL
;
62 const char *file_source
= NULL
;
63 const char *ldap_source
= NULL
;
66 const char *const *cmdline_config
= NULL
;
67 static bool_t got_config_data
= FALSE
;
69 /* high level parsing functions functions */
70 static int parse_ldap_cmd_line(const char *const *cmdline_options
,
71 __nis_ldap_proxy_info
*proxy_info
, __nis_config_t
*nis_config
,
72 __nis_table_mapping_t
**table_mapping
, __nis_config_info_t
*config_info
,
73 __nisdb_table_mapping_t
*table_info
);
74 static int parse_ldap_default_conf(__nis_ldap_proxy_info
*proxy_info
,
75 __nis_config_t
*nis_config
, __nis_config_info_t
*config_info
,
76 __nisdb_table_mapping_t
*table_info
);
77 static int parse_ldap_config_file(const char *config_file
,
78 __nis_ldap_proxy_info
*proxy_info
, __nis_config_t
*nis_config
,
79 __nis_table_mapping_t
**table_mapping
, __nis_config_info_t
*config_info
,
80 __nisdb_table_mapping_t
*table_info
);
81 static int parse_ldap_config_dn_attrs(__nis_ldap_proxy_info
*proxy_info
,
82 __nis_config_t
*nis_config
, __nis_table_mapping_t
**table_mapping
,
83 __nis_config_info_t
*config_info
, __nisdb_table_mapping_t
*table_info
);
84 static int yp_parse_ldap_default_conf(__nis_ldap_proxy_info
*proxy_info
,
85 __nis_config_t
*nis_config
, __nis_config_info_t
*config_info
,
86 __nisdb_table_mapping_t
*table_info
);
88 /* Forward declarations */
89 int yp_parse_ldap_config_file(const char *, __nis_ldap_proxy_info
*,
90 __nis_config_t
*, __nis_table_mapping_t
**, __nis_config_info_t
*,
91 __nisdb_table_mapping_t
*, __yp_domain_context_t
*);
94 /* helper functions */
95 static config_key
get_attrib_num_cmdline(const char *s
,
96 const char **begin_s
, const char **end_s
);
97 static config_key
get_file_attr_val(int fd
, char **attr_val
);
98 static void get_attribute_list(
99 const __nis_ldap_proxy_info
*proxy_info
,
100 const __nis_config_t
*nis_config
,
101 const __nis_config_info_t
*config_info
,
102 const __nisdb_table_mapping_t
*table_info
,
103 char **ldap_config_attributes
);
106 * FUNCTION: parse_ldap_migration
108 * Parses the information for LDAP. The values are first
109 * obtained from the command line, secondly from the preference
110 * file, and finally from an LDAP profile (if so configured in
111 * the command line or preference file). Any unset values will
112 * be set to their default values.
114 * If no command line options, no settings in the /etc/default
115 * configuration file, and no mapping file, then no mapping
120 * -1 Config file stat/open or parse error
121 * 1 No mapping should be used.
123 * INPUT: command line parameters, configuration file
127 parse_ldap_migration(
128 const char *const *cmdline_options
,
129 const char *config_file
)
132 __nis_config_info_t config_info
133 = {NULL
, NULL
, (auth_method_t
)NO_VALUE_SET
,
134 (tls_method_t
)NO_VALUE_SET
, NULL
,
138 p_error
= no_parse_error
;
141 report_info("Getting LDAP configuration", NULL
);
143 initialize_parse_structs(&proxyInfo
, &ldapConfig
, &ldapDBTableMapping
);
146 initialize_yp_parse_structs(&ypDomains
);
148 if (cmdline_options
!= NULL
) {
149 got_config_data
= TRUE
;
150 /* NIS to LDAP does not read command line attributes */
152 rc
= parse_ldap_cmd_line(cmdline_options
, &proxyInfo
,
153 &ldapConfig
, &ldapTableMapping
, &config_info
,
154 &ldapDBTableMapping
);
161 rc
= yp_parse_ldap_default_conf(&proxyInfo
, &ldapConfig
,
162 &config_info
, &ldapDBTableMapping
);
164 rc
= parse_ldap_default_conf(&proxyInfo
, &ldapConfig
,
165 &config_info
, &ldapDBTableMapping
);
168 if (config_file
== NULL
) {
170 if (stat(YP_DEFAULT_MAPPING_FILE
, &buf
) == 0)
171 config_file
= YP_DEFAULT_MAPPING_FILE
;
173 if (stat(DEFAULT_MAPPING_FILE
, &buf
) == 0)
174 config_file
= DEFAULT_MAPPING_FILE
;
178 if (rc
== 0 && config_file
!= NULL
) {
179 got_config_data
= TRUE
;
180 warn_file
= config_file
;
181 cmdline_config
= cmdline_options
;
183 rc
= yp_parse_ldap_config_file(config_file
, &proxyInfo
,
184 &ldapConfig
, &ldapTableMapping
, &config_info
,
185 &ldapDBTableMapping
, &ypDomains
);
187 rc
= parse_ldap_config_file(config_file
, &proxyInfo
,
188 &ldapConfig
, &ldapTableMapping
, &config_info
,
189 &ldapDBTableMapping
);
192 cmdline_config
= NULL
;
194 if (rc
== 0 && (config_info
.config_dn
!= NULL
) &&
195 (config_info
.config_dn
[0] != '\0')) {
196 rc
= parse_ldap_config_dn_attrs(&proxyInfo
,
197 &ldapConfig
, &ldapTableMapping
, &config_info
,
198 &ldapDBTableMapping
);
201 free_config_info(&config_info
);
203 if (rc
== 0 && got_config_data
== FALSE
)
206 set_default_values(&proxyInfo
, &ldapConfig
, &ldapDBTableMapping
);
208 if (yp2ldap
== 1 && rc
== 0) {
209 rc
= second_parser_pass(&ldapTableMapping
);
211 rc
= final_parser_pass(&ldapTableMapping
, &ypDomains
);
217 rc
= finish_parse(&proxyInfo
, &ldapTableMapping
);
220 rc
= linked2hash(ldapTableMapping
);
222 if ((rc
== 0) && yptol_mode
)
223 rc
= map_id_list_init();
226 free_parse_structs();
228 report_info("LDAP configuration complete", NULL
);
233 * FUNCTION: parse_ldap_cmd_line
235 * Parses the information for LDAP from the command line
237 * RETURN VALUE: 0 on success, -1 on failure
239 * INPUT: command line values
244 const char *const *cmdline_options
,
245 __nis_ldap_proxy_info
*proxy_info
,
246 __nis_config_t
*nis_config
,
247 __nis_table_mapping_t
**table_mapping
,
248 __nis_config_info_t
*config_info
,
249 __nisdb_table_mapping_t
*table_info
)
252 config_key attrib_num
;
257 report_info("Command line values: ", NULL
);
258 while (*cmdline_options
!= NULL
) {
260 report_info("\t", *cmdline_options
);
262 attrib_num
= get_attrib_num_cmdline(
263 *cmdline_options
, &begin_s
, &end_s
);
264 if (attrib_num
== key_bad
) {
265 command_line_source
= "command line";
266 report_error(*cmdline_options
, NULL
);
267 command_line_source
= NULL
;
270 } else if (IS_CONFIG_KEYWORD(attrib_num
)) {
271 rc
= add_config_attribute(attrib_num
,
272 begin_s
, end_s
- begin_s
, config_info
);
273 } else if (IS_BIND_INFO(attrib_num
)) {
274 rc
= add_bind_attribute(attrib_num
,
275 begin_s
, end_s
- begin_s
, proxy_info
);
276 } else if (IS_OPER_INFO(attrib_num
)) {
277 rc
= add_operation_attribute(attrib_num
,
278 begin_s
, end_s
- begin_s
, nis_config
,
281 rc
= add_mapping_attribute(attrib_num
,
282 begin_s
, end_s
- begin_s
, table_mapping
);
286 command_line_source
= "command line";
287 report_error(begin_s
, _key_val
);
288 command_line_source
= NULL
;
297 parse_ldap_default_conf(
298 __nis_ldap_proxy_info
*proxy_info
,
299 __nis_config_t
*nis_config
,
300 __nis_config_info_t
*config_info
,
301 __nisdb_table_mapping_t
*table_info
)
304 char *ldap_config_attributes
[n_config_keys
];
309 config_key attrib_num
;
315 if ((defp
= defopen_r(ETCCONFFILE
)) != NULL
) {
316 file_source
= ETCCONFFILE
;
318 report_info("default configuration values: ", NULL
);
319 /* Set defread_r() to be case insensitive */
320 defflags
= defcntl_r(DC_GETFLAGS
, 0, defp
);
321 TURNOFF(defflags
, DC_CASE
);
322 (void) defcntl_r(DC_SETFLAGS
, defflags
, defp
);
324 get_attribute_list(proxy_info
, nis_config
, config_info
,
325 table_info
, ldap_config_attributes
);
327 while ((attr
= ldap_config_attributes
[i
++]) != NULL
) {
328 (void) strlcpy(attr_buf
, attr
, sizeof (attr_buf
));
330 * if nisplusUpdateBatching, make sure
331 * we don't match nisplusUpdateBatchingTimeout
333 if (strcmp(attr
, UPDATE_BATCHING
) == 0) {
334 attr_len
= strlen(attr
);
335 attr_buf
[attr_len
] = '=';
336 attr_buf
[attr_len
+ 1] = '\0';
337 attr_val
= defread_r(attr_buf
, defp
);
340 attr_buf
[attr_len
] = ' ';
341 attr_val
= defread_r(attr_buf
, defp
);
344 attr_buf
[attr_len
] = '\t';
345 attr_val
= defread_r(attr_buf
, defp
);
348 attr_buf
[attr_len
] = '\n';
349 attr_val
= defread_r(attr_buf
, defp
);
352 attr_val
= defread_r(attr_buf
, defp
);
354 if (attr_val
== NULL
)
357 got_config_data
= TRUE
;
358 attrib_num
= get_attrib_num(attr
, strlen(attr
));
359 if (attrib_num
== key_bad
) {
360 report_error(attr
, NULL
);
366 * Allow either entries of the form
371 while (is_whitespace(*attr_val
))
373 if (*attr_val
== '=')
375 while (is_whitespace(*attr_val
))
377 len
= strlen(attr_val
);
378 while (len
> 0 && is_whitespace(attr_val
[len
- 1]))
382 report_info("\t", attr
);
383 report_info("\t\t", attr_val
);
385 if (IS_BIND_INFO(attrib_num
)) {
386 rc
= add_bind_attribute(attrib_num
,
387 attr_val
, len
, proxy_info
);
388 } else if (IS_OPER_INFO(attrib_num
)) {
389 rc
= add_operation_attribute(attrib_num
,
390 attr_val
, len
, nis_config
,
393 if (p_error
!= no_parse_error
) {
394 report_error(attr_val
, attr
);
400 /* Close the /etc/default file */
407 yp_parse_ldap_default_conf(
408 __nis_ldap_proxy_info
*proxy_info
,
409 __nis_config_t
*nis_config
,
410 __nis_config_info_t
*config_info
,
411 __nisdb_table_mapping_t
*table_info
)
414 char *ldap_config_attributes
[n_config_keys
];
419 config_key attrib_num
;
423 if ((defp
= defopen_r(YP_ETCCONFFILE
)) != NULL
) {
424 file_source
= YP_ETCCONFFILE
;
426 report_info("default configuration values: ", NULL
);
427 /* Set defread_r() to be case insensitive */
428 defflags
= defcntl_r(DC_GETFLAGS
, 0, defp
);
429 TURNOFF(defflags
, DC_CASE
);
430 (void) defcntl_r(DC_SETFLAGS
, defflags
, defp
);
432 get_attribute_list(proxy_info
, nis_config
, config_info
,
433 table_info
, ldap_config_attributes
);
435 while ((attr
= ldap_config_attributes
[i
++]) != NULL
) {
436 if ((strlcpy(attr_buf
, attr
, sizeof (attr_buf
))) >=
439 "Static buffer attr_buf overflow", NULL
);
444 if ((attr_val
= defread_r(attr_buf
, defp
)) == NULL
)
447 got_config_data
= TRUE
;
448 attrib_num
= get_attrib_num(attr
, strlen(attr
));
449 if (attrib_num
== key_bad
) {
450 report_error(attr
, NULL
);
456 * Allow either entries of the form
461 while (is_whitespace(*attr_val
))
463 if (*attr_val
== '=')
465 while (is_whitespace(*attr_val
))
467 len
= strlen(attr_val
);
468 while (len
> 0 && is_whitespace(attr_val
[len
- 1]))
472 report_info("\t", attr
);
473 report_info("\t\t", attr_val
);
475 if (IS_YP_BIND_INFO(attrib_num
)) {
476 rc
= add_bind_attribute(attrib_num
,
477 attr_val
, len
, proxy_info
);
478 } else if (IS_YP_OPER_INFO(attrib_num
)) {
479 rc
= add_operation_attribute(attrib_num
,
480 attr_val
, len
, nis_config
,
483 if (p_error
!= no_parse_error
) {
484 report_error(attr_val
, attr
);
490 /* Close the /etc/default file */
497 * FUNCTION: get_attrib_num_cmdline
499 * Parses the information for LDAP from the command line
500 * The form of the command line request is
503 * RETURN VALUE: 0 on success, -1 on failure
505 * INPUT: command line values
509 get_attrib_num_cmdline(
511 const char **begin_s
,
514 const char *s_end
= s
+ strlen(s
);
517 config_key attrib_num
;
519 while (s
< s_end
&& is_whitespace(*s
))
522 for (equal_s
= s
; equal_s
< s_end
; equal_s
++)
523 if (*equal_s
== EQUAL_CHAR
)
526 if (equal_s
== s_end
) {
527 p_error
= parse_bad_command_line_attribute_format
;
531 for (s1
= equal_s
; s1
> s
&& is_whitespace(s1
[-1]); s1
--)
535 p_error
= parse_bad_command_line_attribute_format
;
539 attrib_num
= get_attrib_num(s
, s1
- s
);
541 if (attrib_num
!= key_bad
) {
543 while (s1
< s_end
&& is_whitespace(*s1
))
546 while (s_end
> s1
&& is_whitespace(s_end
[-1]))
555 * FUNCTION: parse_ldap_config_file
557 * Parses the information for LDAP from a configuration
558 * file. If no file is specified, /var/nis/NIS+LDAPmapping
561 * RETURN VALUE: 0 on success, -1 on failure
563 * INPUT: configuration file name
567 parse_ldap_config_file(
568 const char *config_file
,
569 __nis_ldap_proxy_info
*proxy_info
,
570 __nis_config_t
*nis_config
,
571 __nis_table_mapping_t
**table_mapping
,
572 __nis_config_info_t
*config_info
,
573 __nisdb_table_mapping_t
*table_info
)
576 config_key attrib_num
;
581 if ((fd
= open(config_file
, O_RDONLY
)) == -1) {
582 p_error
= parse_open_file_error
;
583 report_error(config_file
, NULL
);
591 report_info("Reading configuration from ", config_file
);
593 file_source
= config_file
;
594 while ((attrib_num
= get_file_attr_val(fd
, &attr_val
)) > 0) {
595 len
= attr_val
== NULL
? 0 : strlen(attr_val
);
596 if (IS_CONFIG_KEYWORD(attrib_num
)) {
597 rc
= add_config_attribute(attrib_num
,
598 attr_val
, len
, config_info
);
599 } else if (IS_BIND_INFO(attrib_num
)) {
600 rc
= add_bind_attribute(attrib_num
,
601 attr_val
, len
, proxy_info
);
602 } else if (IS_OPER_INFO(attrib_num
)) {
603 rc
= add_operation_attribute(attrib_num
,
604 attr_val
, len
, nis_config
, table_info
);
606 rc
= add_mapping_attribute(attrib_num
,
607 attr_val
, len
, table_mapping
);
611 report_error(attr_val
== NULL
?
612 "<no attribute>" : attr_val
, _key_val
);
622 if (attrib_num
== key_bad
) {
623 report_error(_key_val
, NULL
);
632 * FUNCTION: yp_parse_ldap_config_file
634 * Parses the information for LDAP from a configuration
635 * file. If no file is specified, /var/yp/NISLDAPmapping
638 * RETURN VALUE: 0 on success, -1 on failure
640 * INPUT: configuration file name
644 yp_parse_ldap_config_file(
645 const char *config_file
,
646 __nis_ldap_proxy_info
*proxy_info
,
647 __nis_config_t
*nis_config
,
648 __nis_table_mapping_t
**table_mapping
,
649 __nis_config_info_t
*config_info
,
650 __nisdb_table_mapping_t
*table_info
,
651 __yp_domain_context_t
*ypDomains
)
654 config_key attrib_num
;
656 char *attr_val
= NULL
;
659 if ((fd
= open(config_file
, O_RDONLY
)) == -1) {
660 p_error
= parse_open_file_error
;
661 report_error(config_file
, NULL
);
669 report_info("Reading configuration from ", config_file
);
671 file_source
= config_file
;
672 while ((attrib_num
= get_file_attr_val(fd
, &attr_val
)) > 0) {
673 len
= attr_val
== NULL
? 0 : strlen(attr_val
);
674 if (IS_YP_CONFIG_KEYWORD(attrib_num
)) {
675 rc
= add_config_attribute(attrib_num
,
676 attr_val
, len
, config_info
);
677 } else if (IS_YP_BIND_INFO(attrib_num
)) {
678 rc
= add_bind_attribute(attrib_num
,
679 attr_val
, len
, proxy_info
);
680 } else if (IS_YP_OPER_INFO(attrib_num
)) {
681 rc
= add_operation_attribute(attrib_num
,
682 attr_val
, len
, nis_config
, table_info
);
683 } else if (IS_YP_DOMAIN_INFO(attrib_num
)) {
684 rc
= add_ypdomains_attribute(attrib_num
,
685 attr_val
, len
, ypDomains
);
686 } else if (IS_YP_MAP_ATTR(attrib_num
)) {
687 rc
= add_mapping_attribute(attrib_num
,
688 attr_val
, len
, table_mapping
);
691 p_error
= parse_unsupported_format
;
695 report_error(attr_val
== NULL
?
696 "<no attribute>" : attr_val
, _key_val
);
708 if (attrib_num
== key_bad
) {
709 report_error(_key_val
, NULL
);
718 * FUNCTION: get_file_attr_val
720 * Gets the next attribute from the configuration file.
722 * RETURN VALUE: The config key if more attributes
723 * no_more_keys if eof
728 get_file_attr_val(int fd
, char **attr_val
)
737 char *attribute_value
;
739 config_key attrib_num
= no_more_keys
;
743 if ((ret
= read_line(fd
, buf
, sizeof (buf
))) > 0) {
744 for (s
= buf
; is_whitespace(*s
); s
++)
748 while (*s
!= '\0' && !is_whitespace(*s
))
752 report_info("\t", start_tag
);
753 attrib_num
= get_attrib_num(start_tag
, s
- start_tag
);
754 if (attrib_num
== key_bad
)
757 while (is_whitespace(*s
))
763 /* note that read_line will not return a line ending with \ */
764 for (; *s
!= '\0'; s
++) {
765 if (*s
== ESCAPE_CHAR
)
768 while (s
> start_val
&& is_whitespace(s
[-1]))
772 calloc(1, (size_t)(s
- start_val
) + 1);
773 if (attribute_value
== NULL
) {
774 p_error
= parse_no_mem_error
;
777 attr_val
[0] = attribute_value
;
782 for (s
= start_val
; s
< end_val
; s
++) {
783 if (*s
== POUND_SIGN
) {
785 while (s
< end_val
) {
786 if (*s
== DOUBLE_QUOTE_CHAR
||
787 *s
== SINGLE_QUOTE_CHAR
) {
798 for (s
= start_val
; s
< end_val
; s
++)
809 connect_to_ldap_config_server(
812 __nis_config_info_t
*config_info
)
815 int ldapVersion
= LDAP_VERSION3
;
816 int derefOption
= LDAP_DEREF_ALWAYS
;
817 int timelimit
= LDAP_NO_LIMIT
;
818 int sizelimit
= LDAP_NO_LIMIT
;
820 bool_t retrying
= FALSE
;
821 int sleep_seconds
= 1;
824 if (config_info
->tls_method
== no_tls
) {
825 ld
= ldap_init(sever_name
, server_port
);
827 p_error
= parse_ldap_init_error
;
828 report_error(strerror(errno
), NULL
);
832 if ((errnum
= ldapssl_client_init(
833 config_info
->tls_cert_db
, NULL
)) < 0) {
834 p_error
= parse_ldapssl_client_init_error
;
835 report_error(ldapssl_err2string(errnum
), NULL
);
838 ld
= ldapssl_init(sever_name
, server_port
, 1);
840 p_error
= parse_ldapssl_init_error
;
841 report_error(strerror(errno
), NULL
);
846 (void) ldap_set_option(ld
, LDAP_OPT_PROTOCOL_VERSION
,
848 (void) ldap_set_option(ld
, LDAP_OPT_DEREF
, &derefOption
);
849 (void) ldap_set_option(ld
, LDAP_OPT_REFERRALS
, LDAP_OPT_OFF
);
850 (void) ldap_set_option(ld
, LDAP_OPT_TIMELIMIT
, &timelimit
);
851 (void) ldap_set_option(ld
, LDAP_OPT_SIZELIMIT
, &sizelimit
);
854 * Attempt to bind to the LDAP server.
855 * We will loop until success or until an error other
856 * than LDAP_CONNECT_ERROR or LDAP_SERVER_DOWN
859 report_info("Connecting to ", sever_name
);
862 if (config_info
->auth_method
== simple
) {
863 errnum
= ldap_simple_bind_s(ld
, config_info
->proxy_dn
,
864 config_info
->proxy_passwd
);
865 } else if (config_info
->auth_method
== cram_md5
) {
866 cred
.bv_len
= strlen(config_info
->proxy_passwd
);
867 cred
.bv_val
= config_info
->proxy_passwd
;
868 errnum
= ldap_sasl_cram_md5_bind_s(ld
,
869 config_info
->proxy_dn
, &cred
, NULL
, NULL
);
870 } else if (config_info
->auth_method
== digest_md5
) {
871 cred
.bv_len
= strlen(config_info
->proxy_passwd
);
872 cred
.bv_val
= config_info
->proxy_passwd
;
873 errnum
= ldap_x_sasl_digest_md5_bind_s(ld
,
874 config_info
->proxy_dn
, &cred
, NULL
, NULL
);
876 errnum
= ldap_simple_bind_s(ld
, NULL
, NULL
);
879 if (errnum
== LDAP_SUCCESS
)
882 if (errnum
== LDAP_CONNECT_ERROR
||
883 errnum
== LDAP_SERVER_DOWN
) {
887 "LDAP server unavailable. Retrying...",
891 (void) sleep(sleep_seconds
);
893 if (sleep_seconds
> MAX_LDAP_CONFIG_RETRY_TIME
)
894 sleep_seconds
= MAX_LDAP_CONFIG_RETRY_TIME
;
895 p_error
= no_parse_error
;
898 p_error
= parse_ldap_bind_error
;
899 report_error2(config_info
->proxy_dn
, ldap_err2string(errnum
));
900 (void) ldap_unbind(ld
);
905 report_info("Reading values from ", config_info
->config_dn
);
911 * FUNCTION: process_ldap_config_result
913 * Extracts the LDAPMessage containing the nis+/LDAP
916 * RETURN VALUE: 0 on success, -1 on failure
918 * INPUT: LDAP the LDAP connection
919 * LDAPMessage the LDAP message
923 process_ldap_config_result(
925 LDAPMessage
*resultMsg
,
926 __nis_ldap_proxy_info
*proxy_info
,
927 __nis_config_t
*nis_config
,
928 __nis_table_mapping_t
**table_mapping
,
929 __nisdb_table_mapping_t
*table_info
)
934 BerElement
*ber
= NULL
;
935 config_key attrib_num
;
942 bool_t error_reported
= FALSE
;
944 e
= ldap_first_entry(ld
, resultMsg
);
947 for (attr
= ldap_first_attribute(ld
, e
, &ber
); attr
!= NULL
;
948 attr
= ldap_next_attribute(ld
, e
, ber
)) {
950 report_info("\t", attr
);
951 attrib_num
= get_attrib_num(attr
, strlen(attr
));
952 if (attrib_num
== key_bad
) {
953 report_error(attr
, NULL
);
956 if ((vals
= ldap_get_values(ld
, e
, attr
)) != NULL
) {
957 n
= ldap_count_values(vals
);
958 /* parse the attribute values */
959 for (i
= 0; i
< n
; i
++) {
961 while (is_whitespace(*attr_val
))
964 report_info("\t\t", attr_val
);
965 len
= strlen(attr_val
);
967 is_whitespace(attr_val
[len
- 1]))
970 if (IS_YP_BIND_INFO(attrib_num
)) {
971 rc
= add_bind_attribute(attrib_num
, attr_val
,
973 } else if (IS_YP_OPER_INFO(attrib_num
)) {
974 rc
= add_operation_attribute(attrib_num
,
975 attr_val
, len
, nis_config
, table_info
);
976 } else if (IS_YP_MAP_ATTR(attrib_num
)) {
977 rc
= add_mapping_attribute(attrib_num
, attr_val
,
980 p_error
= parse_unsupported_format
;
983 if (IS_BIND_INFO(attrib_num
)) {
984 rc
= add_bind_attribute(attrib_num
, attr_val
,
986 } else if (IS_OPER_INFO(attrib_num
)) {
987 rc
= add_operation_attribute(attrib_num
,
988 attr_val
, len
, nis_config
, table_info
);
990 rc
= add_mapping_attribute(attrib_num
, attr_val
,
994 if (p_error
!= no_parse_error
) {
995 report_error(attr_val
, attr
);
996 error_reported
= TRUE
;
1000 ldap_value_free(vals
);
1002 (void) ldap_get_option(ld
,
1003 LDAP_OPT_ERROR_NUMBER
, &errnum
);
1004 if (errnum
!= LDAP_SUCCESS
)
1005 p_error
= parse_ldap_get_values_error
;
1008 if (p_error
!= no_parse_error
)
1012 errnum
= ldap_result2error(ld
, resultMsg
, FALSE
);
1013 if (errnum
!= LDAP_SUCCESS
)
1014 p_error
= parse_ldap_search_error
;
1019 if (!error_reported
&& p_error
!= no_parse_error
) {
1020 report_error(ldap_err2string(errnum
), 0);
1023 if (p_error
!= no_parse_error
)
1029 * FUNCTION: process_ldap_referral
1031 * Retrieves the configuration for a referral url
1033 * RETURN VALUE: 0 on success, -1 on failure, 1 on skip
1035 * INPUT: url the ldap url
1036 * __nis_ldap_proxy_info
1040 process_ldap_referral(
1043 __nis_ldap_proxy_info
*proxy_info
,
1044 __nis_config_t
*nis_config
,
1045 __nis_table_mapping_t
**table_mapping
,
1046 __nis_config_info_t
*config_info
,
1047 __nisdb_table_mapping_t
*table_info
)
1049 LDAPURLDesc
*ludpp
= NULL
;
1053 LDAPMessage
*resultMsg
= NULL
;
1055 if ((rc
= ldap_url_parse(url
, &ludpp
)) != LDAP_SUCCESS
)
1058 #ifdef LDAP_URL_OPT_SECURE
1059 if (ludpp
->lud_options
& LDAP_URL_OPT_SECURE
) {
1060 if (config_info
->tls_method
!= ssl_tls
) {
1061 ldap_free_urldesc(ludpp
);
1065 if (config_info
->tls_method
!= no_tls
) {
1066 ldap_free_urldesc(ludpp
);
1072 if ((ld
= connect_to_ldap_config_server(ludpp
->lud_host
,
1073 ludpp
->lud_port
, config_info
)) == NULL
) {
1074 ldap_free_urldesc(ludpp
);
1078 errnum
= ldap_search_s(ld
, config_info
->config_dn
, LDAP_SCOPE_BASE
,
1079 "objectclass=nisplusLDAPconfig", attrs
, 0, &resultMsg
);
1081 ldap_source
= config_info
->config_dn
;
1083 if (errnum
!= LDAP_SUCCESS
) {
1084 p_error
= parse_ldap_search_error
;
1085 report_error(ldap_err2string(errnum
), 0);
1088 rc
= process_ldap_config_result(ld
, resultMsg
, proxy_info
,
1089 nis_config
, table_mapping
, table_info
);
1093 (void) ldap_unbind(ld
);
1094 if (resultMsg
!= NULL
)
1095 (void) ldap_msgfree(resultMsg
);
1101 * FUNCTION: process_ldap_referral_msg
1103 * Retrieves the configuration from referred servers
1105 * RETURN VALUE: 0 on success, -1 on failure
1107 * INPUT: LDAP the LDAP connection
1108 * LDAPMessage the LDAP message
1109 * __nis_ldap_proxy_info
1113 process_ldap_referral_msg(
1115 LDAPMessage
*resultMsg
,
1117 __nis_ldap_proxy_info
*proxy_info
,
1118 __nis_config_t
*nis_config
,
1119 __nis_table_mapping_t
**table_mapping
,
1120 __nis_config_info_t
*config_info
,
1121 __nisdb_table_mapping_t
*table_info
)
1124 char **referralsp
= NULL
;
1128 rc
= ldap_parse_result(ld
, resultMsg
, &errCode
, NULL
, NULL
, &referralsp
,
1131 if (rc
!= LDAP_SUCCESS
|| errCode
!= LDAP_REFERRAL
) {
1132 p_error
= parse_ldap_get_values_error
;
1133 report_error(ldap_err2string(errCode
), 0);
1136 for (i
= 0; referralsp
[i
] != NULL
; i
++) {
1137 rc
= process_ldap_referral(referralsp
[i
], attrs
,
1138 proxy_info
, nis_config
, table_mapping
,
1139 config_info
, table_info
);
1143 report_info("Cannot use referral \n",
1148 p_error
= parse_no_available_referrals_error
;
1154 ldap_value_free(referralsp
);
1160 * FUNCTION: parse_ldap_config_dn_attrs
1162 * Parses the information for LDAP from the LDAP profile
1163 * - the profile object name, the LDAP server, and the
1164 * authentication method must be specified.
1166 * RETURN VALUE: 0 on success, -1 on failure
1168 * INPUT: __nis_ldap_proxy_info
1172 parse_ldap_config_dn_attrs(
1173 __nis_ldap_proxy_info
*proxy_info
,
1174 __nis_config_t
*nis_config
,
1175 __nis_table_mapping_t
**table_mapping
,
1176 __nis_config_info_t
*config_info
,
1177 __nisdb_table_mapping_t
*table_info
)
1182 char *ldap_config_attributes
[n_config_keys
];
1183 LDAPMessage
*resultMsg
= NULL
;
1185 /* Determine if properly configured for LDAP lookup */
1186 if (config_info
->auth_method
== simple
&&
1187 config_info
->proxy_dn
== NULL
)
1188 p_error
= parse_no_proxy_dn_error
;
1189 else if (config_info
->auth_method
==
1190 (auth_method_t
)NO_VALUE_SET
)
1191 p_error
= parse_no_config_auth_error
;
1192 else if ((config_info
->default_servers
== NULL
) ||
1193 (config_info
->default_servers
[0] == '\0'))
1194 p_error
= parse_no_config_server_addr
;
1195 if (p_error
!= no_parse_error
) {
1196 report_error(NULL
, NULL
);
1200 if (config_info
->tls_method
== (tls_method_t
)NO_VALUE_SET
)
1201 config_info
->tls_method
= no_tls
;
1202 else if (config_info
->tls_method
== ssl_tls
&&
1203 (config_info
->tls_cert_db
== NULL
||
1204 *config_info
->tls_cert_db
== '\0')) {
1205 p_error
= parse_no_config_cert_db
;
1206 report_error(NULL
, NULL
);
1212 "Getting configuration from LDAP server(s): ",
1213 config_info
->default_servers
);
1215 /* Determine which attributes should be retrieved */
1216 get_attribute_list(proxy_info
, nis_config
, NULL
, table_info
,
1217 ldap_config_attributes
);
1219 if ((ld
= connect_to_ldap_config_server(config_info
->default_servers
, 0,
1220 config_info
)) == NULL
)
1223 /* Get the attribute values */
1224 errnum
= ldap_search_s(ld
, config_info
->config_dn
, LDAP_SCOPE_BASE
,
1225 "objectclass=nisplusLDAPconfig",
1226 ldap_config_attributes
, 0, &resultMsg
);
1227 ldap_source
= config_info
->config_dn
;
1229 if (errnum
== LDAP_REFERRAL
) {
1230 rc
= process_ldap_referral_msg(ld
, resultMsg
,
1231 ldap_config_attributes
, proxy_info
, nis_config
,
1232 table_mapping
, config_info
, table_info
);
1233 } else if (errnum
!= LDAP_SUCCESS
) {
1234 p_error
= parse_ldap_search_error
;
1235 report_error(ldap_err2string(errnum
), 0);
1238 rc
= process_ldap_config_result(ld
, resultMsg
, proxy_info
,
1239 nis_config
, table_mapping
, table_info
);
1243 (void) ldap_unbind(ld
);
1244 if (resultMsg
!= NULL
)
1245 (void) ldap_msgfree(resultMsg
);
1251 is_cmd_line_option(config_key a_num
)
1253 const char *const *cmdline_options
= cmdline_config
;
1254 config_key attrib_num
;
1255 const char *begin_s
;
1258 if (cmdline_options
== NULL
)
1261 while (*cmdline_options
!= NULL
) {
1262 attrib_num
= get_attrib_num_cmdline(
1263 *cmdline_options
, &begin_s
, &end_s
);
1264 if (attrib_num
== a_num
)
1268 return (*cmdline_options
!= NULL
);
1272 * FUNCTION: get_attribute_list
1274 * Get a list of attributes from the LDAP server that have not yet
1275 * been gotten. If config_info is NULL, the associated parameters
1278 * RETURN VALUE: none
1280 * INPUT: Returns a list of parameters in attributes
1281 * which is assumed to be of sufficient size.
1286 const __nis_ldap_proxy_info
*proxy_info
,
1287 const __nis_config_t
*nis_config
,
1288 const __nis_config_info_t
*config_info
,
1289 const __nisdb_table_mapping_t
*table_info
,
1294 /* Determine which attributes should be retrieved */
1297 if (config_info
!= NULL
) {
1299 if (config_info
->config_dn
== NULL
)
1300 attributes
[n_attrs
++] = YP_CONFIG_DN
;
1301 if (config_info
->default_servers
== NULL
)
1302 attributes
[n_attrs
++] = YP_CONFIG_SERVER_LIST
;
1303 if (config_info
->auth_method
==
1304 (auth_method_t
)NO_VALUE_SET
)
1305 attributes
[n_attrs
++] = YP_CONFIG_AUTH_METHOD
;
1306 if (config_info
->tls_method
==
1307 (tls_method_t
)NO_VALUE_SET
)
1308 attributes
[n_attrs
++] = YP_CONFIG_TLS_OPTION
;
1309 if (config_info
->proxy_dn
== NULL
)
1310 attributes
[n_attrs
++] = YP_CONFIG_PROXY_USER
;
1311 if (config_info
->proxy_passwd
== NULL
)
1312 attributes
[n_attrs
++] = YP_CONFIG_PROXY_PASSWD
;
1313 if (config_info
->tls_cert_db
== NULL
)
1314 attributes
[n_attrs
++] = YP_CONFIG_TLS_CERT_DB
;
1316 if (config_info
->config_dn
== NULL
)
1317 attributes
[n_attrs
++] = CONFIG_DN
;
1318 if (config_info
->default_servers
== NULL
)
1319 attributes
[n_attrs
++] = CONFIG_SERVER_LIST
;
1320 if (config_info
->auth_method
==
1321 (auth_method_t
)NO_VALUE_SET
)
1322 attributes
[n_attrs
++] = CONFIG_AUTH_METHOD
;
1323 if (config_info
->tls_method
==
1324 (tls_method_t
)NO_VALUE_SET
)
1325 attributes
[n_attrs
++] = CONFIG_TLS_OPTION
;
1326 if (config_info
->proxy_dn
== NULL
)
1327 attributes
[n_attrs
++] = CONFIG_PROXY_USER
;
1328 if (config_info
->proxy_passwd
== NULL
)
1329 attributes
[n_attrs
++] = CONFIG_PROXY_PASSWD
;
1330 if (config_info
->tls_cert_db
== NULL
)
1331 attributes
[n_attrs
++] = CONFIG_TLS_CERT_DB
;
1335 attributes
[n_attrs
++] = YP_DOMAIN_CONTEXT
;
1336 attributes
[n_attrs
++] = YPPASSWDD_DOMAINS
;
1337 attributes
[n_attrs
++] = YP_DB_ID_MAP
;
1338 attributes
[n_attrs
++] = YP_COMMENT_CHAR
;
1339 attributes
[n_attrs
++] = YP_MAP_FLAGS
;
1340 attributes
[n_attrs
++] = YP_ENTRY_TTL
;
1341 attributes
[n_attrs
++] = YP_NAME_FIELDS
;
1342 attributes
[n_attrs
++] = YP_SPLIT_FIELD
;
1343 attributes
[n_attrs
++] = YP_REPEATED_FIELD_SEPARATORS
;
1344 attributes
[n_attrs
++] = YP_LDAP_OBJECT_DN
;
1345 attributes
[n_attrs
++] = NIS_TO_LDAP_MAP
;
1346 attributes
[n_attrs
++] = LDAP_TO_NIS_MAP
;
1348 attributes
[n_attrs
++] = DB_ID_MAP
;
1349 attributes
[n_attrs
++] = ENTRY_TTL
;
1350 attributes
[n_attrs
++] = LDAP_OBJECT_DN
;
1351 attributes
[n_attrs
++] = NISPLUS_TO_LDAP_MAP
;
1352 attributes
[n_attrs
++] = LDAP_TO_NISPLUS_MAP
;
1357 if (proxy_info
->default_servers
== NULL
)
1358 attributes
[n_attrs
++] = PREFERRED_SERVERS
;
1359 if (proxy_info
->auth_method
== (auth_method_t
)NO_VALUE_SET
)
1360 attributes
[n_attrs
++] = AUTH_METHOD
;
1361 if (proxy_info
->tls_method
== (tls_method_t
)NO_VALUE_SET
)
1362 attributes
[n_attrs
++] = YP_TLS_OPTION
;
1363 if (proxy_info
->tls_cert_db
== NULL
)
1364 attributes
[n_attrs
++] = YP_TLS_CERT_DB
;
1365 if (proxy_info
->default_search_base
== NULL
)
1366 attributes
[n_attrs
++] = SEARCH_BASE
;
1367 if (proxy_info
->proxy_dn
== NULL
)
1368 attributes
[n_attrs
++] = YP_PROXY_USER
;
1369 if (proxy_info
->proxy_passwd
== NULL
)
1370 attributes
[n_attrs
++] = YP_PROXY_PASSWD
;
1371 if (proxy_info
->default_nis_domain
== NULL
)
1372 attributes
[n_attrs
++] = YP_LDAP_BASE_DOMAIN
;
1373 if (proxy_info
->bind_timeout
.tv_sec
==
1374 (time_t)NO_VALUE_SET
)
1375 attributes
[n_attrs
++] = YP_BIND_TIMEOUT
;
1376 if (proxy_info
->search_timeout
.tv_sec
==
1377 (time_t)NO_VALUE_SET
)
1378 attributes
[n_attrs
++] = YP_SEARCH_TIMEOUT
;
1379 if (proxy_info
->modify_timeout
.tv_sec
==
1380 (time_t)NO_VALUE_SET
)
1381 attributes
[n_attrs
++] = YP_MODIFY_TIMEOUT
;
1382 if (proxy_info
->add_timeout
.tv_sec
== (time_t)NO_VALUE_SET
)
1383 attributes
[n_attrs
++] = YP_ADD_TIMEOUT
;
1384 if (proxy_info
->delete_timeout
.tv_sec
==
1385 (time_t)NO_VALUE_SET
)
1386 attributes
[n_attrs
++] = YP_DELETE_TIMEOUT
;
1387 if (proxy_info
->search_time_limit
== (int)NO_VALUE_SET
)
1388 attributes
[n_attrs
++] = YP_SEARCH_TIME_LIMIT
;
1389 if (proxy_info
->search_size_limit
== (int)NO_VALUE_SET
)
1390 attributes
[n_attrs
++] = YP_SEARCH_SIZE_LIMIT
;
1391 if (proxy_info
->follow_referral
==
1392 (follow_referral_t
)NO_VALUE_SET
)
1393 attributes
[n_attrs
++] = YP_FOLLOW_REFERRAL
;
1395 if (table_info
->retrieveError
==
1396 (__nis_retrieve_error_t
)NO_VALUE_SET
)
1397 attributes
[n_attrs
++] = YP_RETRIEVE_ERROR_ACTION
;
1398 if (table_info
->retrieveErrorRetry
.attempts
== NO_VALUE_SET
)
1399 attributes
[n_attrs
++] = YP_RETREIVE_ERROR_ATTEMPTS
;
1400 if (table_info
->retrieveErrorRetry
.timeout
==
1401 (time_t)NO_VALUE_SET
)
1402 attributes
[n_attrs
++] = YP_RETREIVE_ERROR_TIMEOUT
;
1403 if (table_info
->storeError
==
1404 (__nis_store_error_t
)NO_VALUE_SET
)
1405 attributes
[n_attrs
++] = YP_STORE_ERROR_ACTION
;
1406 if (table_info
->storeErrorRetry
.attempts
== NO_VALUE_SET
)
1407 attributes
[n_attrs
++] = YP_STORE_ERROR_ATTEMPTS
;
1408 if (table_info
->storeErrorRetry
.timeout
==
1409 (time_t)NO_VALUE_SET
)
1410 attributes
[n_attrs
++] = YP_STORE_ERROR_TIMEOUT
;
1411 if (table_info
->refreshError
==
1412 (__nis_refresh_error_t
)NO_VALUE_SET
)
1413 attributes
[n_attrs
++] = REFRESH_ERROR_ACTION
;
1414 if (table_info
->refreshErrorRetry
.attempts
== NO_VALUE_SET
)
1415 attributes
[n_attrs
++] = REFRESH_ERROR_ATTEMPTS
;
1416 if (table_info
->refreshErrorRetry
.timeout
==
1417 (time_t)NO_VALUE_SET
)
1418 attributes
[n_attrs
++] = REFRESH_ERROR_TIMEOUT
;
1419 if (table_info
->matchFetch
==
1420 (__nis_match_fetch_t
)NO_VALUE_SET
)
1421 attributes
[n_attrs
++] = YP_MATCH_FETCH
;
1423 if (proxy_info
->default_servers
== NULL
)
1424 attributes
[n_attrs
++] = PREFERRED_SERVERS
;
1425 if (proxy_info
->auth_method
== (auth_method_t
)NO_VALUE_SET
)
1426 attributes
[n_attrs
++] = AUTH_METHOD
;
1427 if (proxy_info
->tls_method
== (tls_method_t
)NO_VALUE_SET
)
1428 attributes
[n_attrs
++] = TLS_OPTION
;
1429 if (proxy_info
->tls_cert_db
== NULL
)
1430 attributes
[n_attrs
++] = TLS_CERT_DB
;
1431 if (proxy_info
->default_search_base
== NULL
)
1432 attributes
[n_attrs
++] = SEARCH_BASE
;
1433 if (proxy_info
->proxy_dn
== NULL
)
1434 attributes
[n_attrs
++] = PROXY_USER
;
1435 if (proxy_info
->proxy_passwd
== NULL
)
1436 attributes
[n_attrs
++] = PROXY_PASSWD
;
1437 if (proxy_info
->default_nis_domain
== NULL
)
1438 attributes
[n_attrs
++] = LDAP_BASE_DOMAIN
;
1439 if (proxy_info
->bind_timeout
.tv_sec
==
1440 (time_t)NO_VALUE_SET
)
1441 attributes
[n_attrs
++] = BIND_TIMEOUT
;
1442 if (proxy_info
->search_timeout
.tv_sec
==
1443 (time_t)NO_VALUE_SET
)
1444 attributes
[n_attrs
++] = SEARCH_TIMEOUT
;
1445 if (proxy_info
->modify_timeout
.tv_sec
==
1446 (time_t)NO_VALUE_SET
)
1447 attributes
[n_attrs
++] = MODIFY_TIMEOUT
;
1448 if (proxy_info
->add_timeout
.tv_sec
== (time_t)NO_VALUE_SET
)
1449 attributes
[n_attrs
++] = ADD_TIMEOUT
;
1450 if (proxy_info
->delete_timeout
.tv_sec
==
1451 (time_t)NO_VALUE_SET
)
1452 attributes
[n_attrs
++] = DELETE_TIMEOUT
;
1453 if (proxy_info
->search_time_limit
== (int)NO_VALUE_SET
)
1454 attributes
[n_attrs
++] = SEARCH_TIME_LIMIT
;
1455 if (proxy_info
->search_size_limit
== (int)NO_VALUE_SET
)
1456 attributes
[n_attrs
++] = SEARCH_SIZE_LIMIT
;
1457 if (proxy_info
->follow_referral
==
1458 (follow_referral_t
)NO_VALUE_SET
)
1459 attributes
[n_attrs
++] = FOLLOW_REFERRAL
;
1461 if (table_info
->retrieveError
==
1462 (__nis_retrieve_error_t
)NO_VALUE_SET
)
1463 attributes
[n_attrs
++] = RETRIEVE_ERROR_ACTION
;
1464 if (table_info
->retrieveErrorRetry
.attempts
== NO_VALUE_SET
)
1465 attributes
[n_attrs
++] = RETREIVE_ERROR_ATTEMPTS
;
1466 if (table_info
->retrieveErrorRetry
.timeout
==
1467 (time_t)NO_VALUE_SET
)
1468 attributes
[n_attrs
++] = RETREIVE_ERROR_TIMEOUT
;
1469 if (table_info
->storeError
==
1470 (__nis_store_error_t
)NO_VALUE_SET
)
1471 attributes
[n_attrs
++] = STORE_ERROR_ACTION
;
1472 if (table_info
->storeErrorRetry
.attempts
== NO_VALUE_SET
)
1473 attributes
[n_attrs
++] = STORE_ERROR_ATTEMPTS
;
1474 if (table_info
->storeErrorRetry
.timeout
==
1475 (time_t)NO_VALUE_SET
)
1476 attributes
[n_attrs
++] = STORE_ERROR_TIMEOUT
;
1477 if (table_info
->refreshError
==
1478 (__nis_refresh_error_t
)NO_VALUE_SET
)
1479 attributes
[n_attrs
++] = REFRESH_ERROR_ACTION
;
1480 if (table_info
->refreshErrorRetry
.attempts
== NO_VALUE_SET
)
1481 attributes
[n_attrs
++] = REFRESH_ERROR_ATTEMPTS
;
1482 if (table_info
->refreshErrorRetry
.timeout
==
1483 (time_t)NO_VALUE_SET
)
1484 attributes
[n_attrs
++] = REFRESH_ERROR_TIMEOUT
;
1485 if (table_info
->matchFetch
==
1486 (__nis_match_fetch_t
)NO_VALUE_SET
)
1487 attributes
[n_attrs
++] = MATCH_FETCH
;
1490 switch (nis_config
->initialUpdate
) {
1491 case (__nis_initial_update_t
)NO_VALUE_SET
:
1492 attributes
[n_attrs
++] = INITIAL_UPDATE_ACTION
;
1493 attributes
[n_attrs
++] = INITIAL_UPDATE_ONLY
;
1495 case (__nis_initial_update_t
)INITIAL_UPDATE_NO_ACTION
:
1496 case (__nis_initial_update_t
)NO_INITIAL_UPDATE_NO_ACTION
:
1497 attributes
[n_attrs
++] = INITIAL_UPDATE_ACTION
;
1499 case (__nis_initial_update_t
)FROM_NO_INITIAL_UPDATE
:
1500 case (__nis_initial_update_t
)TO_NO_INITIAL_UPDATE
:
1501 attributes
[n_attrs
++] = INITIAL_UPDATE_ONLY
;
1505 if (nis_config
->threadCreationError
==
1506 (__nis_thread_creation_error_t
)NO_VALUE_SET
)
1507 attributes
[n_attrs
++] = THREAD_CREATE_ERROR_ACTION
;
1508 if (nis_config
->threadCreationErrorTimeout
.attempts
== NO_VALUE_SET
)
1509 attributes
[n_attrs
++] = THREAD_CREATE_ERROR_ATTEMPTS
;
1510 if (nis_config
->threadCreationErrorTimeout
.timeout
==
1511 (time_t)NO_VALUE_SET
)
1512 attributes
[n_attrs
++] = THREAD_CREATE_ERROR_TIMEOUT
;
1513 if (nis_config
->dumpError
== (__nis_dump_error_t
)NO_VALUE_SET
)
1514 attributes
[n_attrs
++] = DUMP_ERROR_ACTION
;
1515 if (nis_config
->dumpErrorTimeout
.attempts
== NO_VALUE_SET
)
1516 attributes
[n_attrs
++] = DUMP_ERROR_ATTEMPTS
;
1517 if (nis_config
->dumpErrorTimeout
.timeout
== (time_t)NO_VALUE_SET
)
1518 attributes
[n_attrs
++] = DUMP_ERROR_TIMEOUT
;
1519 if (nis_config
->resyncService
== (__nis_resync_service_t
)NO_VALUE_SET
)
1520 attributes
[n_attrs
++] = RESYNC
;
1521 if (nis_config
->updateBatching
==
1522 (__nis_update_batching_t
)NO_VALUE_SET
)
1523 attributes
[n_attrs
++] = UPDATE_BATCHING
;
1524 if (nis_config
->updateBatchingTimeout
.timeout
== (time_t)NO_VALUE_SET
)
1525 attributes
[n_attrs
++] = UPDATE_BATCHING_TIMEOUT
;
1526 if (nis_config
->numberOfServiceThreads
== (int)NO_VALUE_SET
)
1527 attributes
[n_attrs
++] = NUMBER_THEADS
;
1528 if (nis_config
->emulate_yp
== (int)NO_VALUE_SET
)
1529 attributes
[n_attrs
++] = YP_EMULATION
;
1531 /* maxRPCRecordSize is not configurable through LDAP profiles */
1532 if (nis_config
->maxRPCRecordSize
== (int)NO_VALUE_SET
)
1533 attributes
[n_attrs
++] = MAX_RPC_RECSIZE
;
1535 attributes
[n_attrs
++] = NULL
;
1539 * Notes on adding new attributes
1540 * 1. Determine where the attribute value will be saved
1541 * Currently, the following structures are defined:
1542 * __nis_config_info_t config_info
1543 * __nis_ldap_proxy_info proxyInfo
1544 * __nis_config_t ldapConfig
1545 * __nisdb_table_mapping_t ldapDBTableMapping
1546 * __nis_table_mapping_t ldapTableMapping
1547 * or add a new structure or variable - this will require
1549 * 2. Initialize the value to a known unconfigured value.
1550 * This can be done in initialize_parse_structs or
1551 * parse_ldap_migration.
1552 * 3. In the header file nis_parse_ldap_conf.h, add the name
1553 * of the attribute. (Currently, the attribute name is assumed
1554 * to be the same for the command line, the preference file,
1555 * and LDAP.) The names are grouped logically. Add a corresponding
1556 * config_key to the enum. Note that position in this file is
1557 * essential because the macros such as IS_BIND_INFO depend on
1558 * the sequence. The corresponding macro (IS_CONFIG_KEYWORD,
1559 * IS_BIND_INFO, or IS_OPER_INFO) may need to be adjusted. These
1560 * are used to partition the attributes into smaller chunks.
1561 * 4. Add the correspond entry to the keyword_lookup array in
1562 * nis_parse_ldap_attr.c, which is used to determine the config_key
1563 * from the corresponding key word.
1564 * 5. Add the attribute to the list of attributes to retrieve from
1565 * the LDAP server if no value has been set in the function
1566 * parse_ldap_config_dn_attrs. (This assumes that the attribute
1567 * is not used to get the configuration from the LDAP server.)
1568 * 6. Add logic to parse the individual attribute in
1569 * add_config_attribute, add_bind_attribute,
1570 * add_operation_attribute, or add_mapping_attribute depending
1571 * which group of attributes the added attribute belongs to.
1572 * 7. In set_default_values, if the attribute value has not been set, set
1573 * the default value. If any additional fixup is needed depending
1574 * on other configuration values, it should be done here.
1575 * 8. If an attribute name is a subset of another, parse_ldap_default_conf
1576 * should be modified.