xref: /illumos-gate/usr/src/lib/libnisdb/nis_parse_ldap_attr.c (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #include <stdio.h>
28*7c478bd9Sstevel@tonic-gate #include <string.h>
29*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
30*7c478bd9Sstevel@tonic-gate #include <ctype.h>
31*7c478bd9Sstevel@tonic-gate #include <fcntl.h>
32*7c478bd9Sstevel@tonic-gate #include <unistd.h>
33*7c478bd9Sstevel@tonic-gate #include <errno.h>
34*7c478bd9Sstevel@tonic-gate #include <locale.h>
35*7c478bd9Sstevel@tonic-gate #include <lber.h>
36*7c478bd9Sstevel@tonic-gate #include <ldap.h>
37*7c478bd9Sstevel@tonic-gate #include <syslog.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #include "ldap_parse.h"
40*7c478bd9Sstevel@tonic-gate #include "nis_parse_ldap_conf.h"
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate extern FILE *cons;
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate static bool_t get_timeval_t(const char *s, int len, struct timeval *t,
45*7c478bd9Sstevel@tonic-gate 	time_t default_val);
46*7c478bd9Sstevel@tonic-gate static bool_t get_limit(const char *s, int len, int *limit, int default_val);
47*7c478bd9Sstevel@tonic-gate static bool_t get_time_t(const char *s, time_t *t, time_t default_val);
48*7c478bd9Sstevel@tonic-gate static bool_t get_uint_val(const char *attrib_val, int *val, int default_val);
49*7c478bd9Sstevel@tonic-gate static bool_t get_int_val(const char *attrib_val, int *val, int default_val);
50*7c478bd9Sstevel@tonic-gate static void warn_duplicate_val(config_key attrib_num);
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate static struct {
53*7c478bd9Sstevel@tonic-gate 	const char	*key_name;
54*7c478bd9Sstevel@tonic-gate 	config_key	key_id;
55*7c478bd9Sstevel@tonic-gate } keyword_lookup[] = {
56*7c478bd9Sstevel@tonic-gate 	{CONFIG_DN,		key_config_dn},
57*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_DN,	key_yp_config_dn},
58*7c478bd9Sstevel@tonic-gate 	{CONFIG_SERVER_LIST,	key_config_server_list},
59*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_SERVER_LIST,	key_yp_config_server_list},
60*7c478bd9Sstevel@tonic-gate 	{CONFIG_AUTH_METHOD,	key_config_auth_method},
61*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_AUTH_METHOD,	key_yp_config_auth_method},
62*7c478bd9Sstevel@tonic-gate 	{CONFIG_TLS_OPTION,		key_config_tls_option},
63*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_TLS_OPTION,	key_yp_config_tls_option},
64*7c478bd9Sstevel@tonic-gate 	{CONFIG_TLS_CERT_DB,	key_config_tls_certificate_db},
65*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_TLS_CERT_DB,	key_yp_config_tls_certificate_db},
66*7c478bd9Sstevel@tonic-gate 	{CONFIG_PROXY_USER,		key_config_proxy_user},
67*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_PROXY_USER,	key_yp_config_proxy_user},
68*7c478bd9Sstevel@tonic-gate 	{CONFIG_PROXY_PASSWD,	key_config_proxy_passwd},
69*7c478bd9Sstevel@tonic-gate 	{YP_CONFIG_PROXY_PASSWD,	key_yp_config_proxy_passwd},
70*7c478bd9Sstevel@tonic-gate 	{PREFERRED_SERVERS,		key_preferred_servers},
71*7c478bd9Sstevel@tonic-gate 	{AUTH_METHOD,		key_auth_method},
72*7c478bd9Sstevel@tonic-gate 	{TLS_OPTION,		key_tls_option},
73*7c478bd9Sstevel@tonic-gate 	{YP_TLS_OPTION,		key_yp_tls_option},
74*7c478bd9Sstevel@tonic-gate 	{TLS_CERT_DB,		key_tls_certificate_db},
75*7c478bd9Sstevel@tonic-gate 	{YP_TLS_CERT_DB,	key_yp_tls_certificate_db},
76*7c478bd9Sstevel@tonic-gate 	{SEARCH_BASE,		key_search_base},
77*7c478bd9Sstevel@tonic-gate 	{PROXY_USER,		key_proxy_user},
78*7c478bd9Sstevel@tonic-gate 	{YP_PROXY_USER,		key_yp_proxy_user},
79*7c478bd9Sstevel@tonic-gate 	{PROXY_PASSWD,		key_proxy_passwd},
80*7c478bd9Sstevel@tonic-gate 	{YP_PROXY_PASSWD,	key_yp_proxy_passwd},
81*7c478bd9Sstevel@tonic-gate 	{LDAP_BASE_DOMAIN,	key_ldap_base_domain},
82*7c478bd9Sstevel@tonic-gate 	{YP_LDAP_BASE_DOMAIN,	key_yp_ldap_base_domain},
83*7c478bd9Sstevel@tonic-gate 	{BIND_TIMEOUT,		key_bind_timeout},
84*7c478bd9Sstevel@tonic-gate 	{YP_BIND_TIMEOUT,	key_yp_bind_timeout},
85*7c478bd9Sstevel@tonic-gate 	{SEARCH_TIMEOUT,	key_search_timeout},
86*7c478bd9Sstevel@tonic-gate 	{YP_SEARCH_TIMEOUT,	key_yp_search_timeout},
87*7c478bd9Sstevel@tonic-gate 	{MODIFY_TIMEOUT,	key_modify_timeout},
88*7c478bd9Sstevel@tonic-gate 	{YP_MODIFY_TIMEOUT,	key_yp_modify_timeout},
89*7c478bd9Sstevel@tonic-gate 	{ADD_TIMEOUT,		key_add_timeout},
90*7c478bd9Sstevel@tonic-gate 	{YP_ADD_TIMEOUT,	key_yp_add_timeout},
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate 	{DELETE_TIMEOUT,	key_delete_timeout},
93*7c478bd9Sstevel@tonic-gate 	{YP_DELETE_TIMEOUT,	key_yp_delete_timeout},
94*7c478bd9Sstevel@tonic-gate 	{SEARCH_TIME_LIMIT,	key_search_time_limit},
95*7c478bd9Sstevel@tonic-gate 	{YP_SEARCH_TIME_LIMIT,	key_yp_search_time_limit},
96*7c478bd9Sstevel@tonic-gate 	{SEARCH_SIZE_LIMIT,	key_search_size_limit},
97*7c478bd9Sstevel@tonic-gate 	{YP_SEARCH_SIZE_LIMIT,	key_yp_search_size_limit},
98*7c478bd9Sstevel@tonic-gate 	{FOLLOW_REFERRAL,	key_follow_referral},
99*7c478bd9Sstevel@tonic-gate 	{YP_FOLLOW_REFERRAL,	key_yp_follow_referral},
100*7c478bd9Sstevel@tonic-gate 	{INITIAL_UPDATE_ACTION,	key_initial_update_action},
101*7c478bd9Sstevel@tonic-gate 	{INITIAL_UPDATE_ONLY,	key_initial_update_only},
102*7c478bd9Sstevel@tonic-gate 	{RETRIEVE_ERROR_ACTION,	key_retrieve_error_action},
103*7c478bd9Sstevel@tonic-gate 	{YP_RETRIEVE_ERROR_ACTION,	key_yp_retrieve_error_action},
104*7c478bd9Sstevel@tonic-gate 	{RETREIVE_ERROR_ATTEMPTS,
105*7c478bd9Sstevel@tonic-gate 				key_retrieve_error_attempts},
106*7c478bd9Sstevel@tonic-gate 	{YP_RETREIVE_ERROR_ATTEMPTS,
107*7c478bd9Sstevel@tonic-gate 				key_yp_retrieve_error_attempts},
108*7c478bd9Sstevel@tonic-gate 	{RETREIVE_ERROR_TIMEOUT,
109*7c478bd9Sstevel@tonic-gate 				key_retreive_error_timeout},
110*7c478bd9Sstevel@tonic-gate 	{YP_RETREIVE_ERROR_TIMEOUT,
111*7c478bd9Sstevel@tonic-gate 				key_yp_retreive_error_timeout},
112*7c478bd9Sstevel@tonic-gate 	{STORE_ERROR_ACTION,	key_store_error_action},
113*7c478bd9Sstevel@tonic-gate 	{YP_STORE_ERROR_ACTION,	key_yp_store_error_action},
114*7c478bd9Sstevel@tonic-gate 	{STORE_ERROR_ATTEMPTS,	key_store_error_attempts},
115*7c478bd9Sstevel@tonic-gate 	{YP_STORE_ERROR_ATTEMPTS,	key_yp_store_error_attempts},
116*7c478bd9Sstevel@tonic-gate 	{STORE_ERROR_TIMEOUT,	key_store_error_timeout},
117*7c478bd9Sstevel@tonic-gate 	{YP_STORE_ERROR_TIMEOUT,	key_yp_store_error_timeout},
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate 	{REFRESH_ERROR_ACTION,	key_refresh_error_action},
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate 	{REFRESH_ERROR_ATTEMPTS,
122*7c478bd9Sstevel@tonic-gate 				key_refresh_error_attempts},
123*7c478bd9Sstevel@tonic-gate 	{REFRESH_ERROR_TIMEOUT,	key_refresh_error_timeout},
124*7c478bd9Sstevel@tonic-gate 	{THREAD_CREATE_ERROR_ACTION,
125*7c478bd9Sstevel@tonic-gate 				key_thread_create_error_action},
126*7c478bd9Sstevel@tonic-gate 	{THREAD_CREATE_ERROR_ATTEMPTS,
127*7c478bd9Sstevel@tonic-gate 				key_thread_create_error_attempts},
128*7c478bd9Sstevel@tonic-gate 	{THREAD_CREATE_ERROR_TIMEOUT,
129*7c478bd9Sstevel@tonic-gate 				key_thread_create_error_timeout},
130*7c478bd9Sstevel@tonic-gate 	{DUMP_ERROR_ACTION,	key_dump_error_action},
131*7c478bd9Sstevel@tonic-gate 	{DUMP_ERROR_ATTEMPTS,	key_dump_error_attempts},
132*7c478bd9Sstevel@tonic-gate 	{DUMP_ERROR_TIMEOUT,	key_dump_error_timeout},
133*7c478bd9Sstevel@tonic-gate 	{RESYNC,		key_resync},
134*7c478bd9Sstevel@tonic-gate 	{UPDATE_BATCHING,	key_update_batching},
135*7c478bd9Sstevel@tonic-gate 	{UPDATE_BATCHING_TIMEOUT,
136*7c478bd9Sstevel@tonic-gate 				key_update_batching_timeout},
137*7c478bd9Sstevel@tonic-gate 	{MATCH_FETCH,		key_match_fetch},
138*7c478bd9Sstevel@tonic-gate 	{YP_MATCH_FETCH,	key_yp_match_fetch},
139*7c478bd9Sstevel@tonic-gate 	{NUMBER_THEADS,		key_number_threads},
140*7c478bd9Sstevel@tonic-gate 	{YP_EMULATION,		key_yp_emulation},
141*7c478bd9Sstevel@tonic-gate 	{MAX_RPC_RECSIZE,	key_max_rpc_recsize},
142*7c478bd9Sstevel@tonic-gate 	{YP_DOMAIN_CONTEXT,	key_yp_domain_context},
143*7c478bd9Sstevel@tonic-gate 	{YPPASSWDD_DOMAINS,	key_yppasswdd_domains},
144*7c478bd9Sstevel@tonic-gate 	{DB_ID_MAP,		key_db_id_map},
145*7c478bd9Sstevel@tonic-gate 	{YP_DB_ID_MAP,	key_yp_db_id_map},
146*7c478bd9Sstevel@tonic-gate 	{YP_COMMENT_CHAR,	key_yp_comment_char},
147*7c478bd9Sstevel@tonic-gate 	{YP_MAP_FLAGS,		key_yp_map_flags},
148*7c478bd9Sstevel@tonic-gate 	{ENTRY_TTL,		key_entry_ttl},
149*7c478bd9Sstevel@tonic-gate 	{YP_ENTRY_TTL,	key_yp_entry_ttl},
150*7c478bd9Sstevel@tonic-gate 	{YP_NAME_FIELDS,	key_yp_name_fields},
151*7c478bd9Sstevel@tonic-gate 	{YP_SPLIT_FIELD,	key_yp_split_field},
152*7c478bd9Sstevel@tonic-gate 	{YP_REPEATED_FIELD_SEPARATORS,	key_yp_repeated_field_separators},
153*7c478bd9Sstevel@tonic-gate 	{LDAP_OBJECT_DN,	key_ldap_object_dn},
154*7c478bd9Sstevel@tonic-gate 	{YP_LDAP_OBJECT_DN,	key_yp_ldap_object_dn},
155*7c478bd9Sstevel@tonic-gate 	{LDAP_TO_NISPLUS_MAP,	key_ldap_to_nisplus_map},
156*7c478bd9Sstevel@tonic-gate 	{LDAP_TO_NIS_MAP,	key_ldap_to_nis_map},
157*7c478bd9Sstevel@tonic-gate 	{NISPLUS_TO_LDAP_MAP,	key_nisplus_to_ldap_map},
158*7c478bd9Sstevel@tonic-gate 	{NIS_TO_LDAP_MAP,	key_nis_to_ldap_map}
159*7c478bd9Sstevel@tonic-gate };
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate  * FUNCTION:	add_config_attribute
163*7c478bd9Sstevel@tonic-gate  *
164*7c478bd9Sstevel@tonic-gate  *	Adds the attribute value to __nis_config_info_t
165*7c478bd9Sstevel@tonic-gate  *	if the value is not yet set.
166*7c478bd9Sstevel@tonic-gate  *
167*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	0 on success, -1 on failure
168*7c478bd9Sstevel@tonic-gate  *
169*7c478bd9Sstevel@tonic-gate  * INPUT:		attribute number and value (assumed to be non-NULL)
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate int
add_config_attribute(config_key attrib_num,const char * attrib_val,int attrib_len,__nis_config_info_t * config_info)173*7c478bd9Sstevel@tonic-gate add_config_attribute(
174*7c478bd9Sstevel@tonic-gate 	config_key		attrib_num,
175*7c478bd9Sstevel@tonic-gate 	const char		*attrib_val,
176*7c478bd9Sstevel@tonic-gate 	int			attrib_len,
177*7c478bd9Sstevel@tonic-gate 	__nis_config_info_t	*config_info)
178*7c478bd9Sstevel@tonic-gate {
179*7c478bd9Sstevel@tonic-gate 	switch (attrib_num) {
180*7c478bd9Sstevel@tonic-gate 		case key_yp_config_dn:
181*7c478bd9Sstevel@tonic-gate 		case key_config_dn:
182*7c478bd9Sstevel@tonic-gate 			if (config_info->config_dn == NULL) {
183*7c478bd9Sstevel@tonic-gate 				if (!validate_dn(attrib_val, attrib_len))
184*7c478bd9Sstevel@tonic-gate 					break;
185*7c478bd9Sstevel@tonic-gate 				config_info->config_dn =
186*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
187*7c478bd9Sstevel@tonic-gate 			} else {
188*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
189*7c478bd9Sstevel@tonic-gate 			}
190*7c478bd9Sstevel@tonic-gate 			break;
191*7c478bd9Sstevel@tonic-gate 		case key_yp_config_server_list:
192*7c478bd9Sstevel@tonic-gate 		case key_config_server_list:
193*7c478bd9Sstevel@tonic-gate 			if (config_info->default_servers == NULL) {
194*7c478bd9Sstevel@tonic-gate 				config_info->default_servers =
195*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
196*7c478bd9Sstevel@tonic-gate 			} else {
197*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
198*7c478bd9Sstevel@tonic-gate 			}
199*7c478bd9Sstevel@tonic-gate 			break;
200*7c478bd9Sstevel@tonic-gate 		case key_yp_config_auth_method:
201*7c478bd9Sstevel@tonic-gate 		case key_config_auth_method:
202*7c478bd9Sstevel@tonic-gate 			if (config_info->auth_method ==
203*7c478bd9Sstevel@tonic-gate 			    (auth_method_t)NO_VALUE_SET) {
204*7c478bd9Sstevel@tonic-gate 				if (same_string("none", attrib_val,
205*7c478bd9Sstevel@tonic-gate 						attrib_len))
206*7c478bd9Sstevel@tonic-gate 					config_info->auth_method = none;
207*7c478bd9Sstevel@tonic-gate 				else if (same_string("simple", attrib_val,
208*7c478bd9Sstevel@tonic-gate 						attrib_len))
209*7c478bd9Sstevel@tonic-gate 					config_info->auth_method = simple;
210*7c478bd9Sstevel@tonic-gate 				else if (same_string("sasl/cram-md5",
211*7c478bd9Sstevel@tonic-gate 						attrib_val, attrib_len))
212*7c478bd9Sstevel@tonic-gate 					config_info->auth_method = cram_md5;
213*7c478bd9Sstevel@tonic-gate 				else if (same_string("sasl/digest-md5",
214*7c478bd9Sstevel@tonic-gate 						attrib_val, attrib_len))
215*7c478bd9Sstevel@tonic-gate 					config_info->auth_method = digest_md5;
216*7c478bd9Sstevel@tonic-gate 				else
217*7c478bd9Sstevel@tonic-gate 					p_error = parse_bad_auth_method_error;
218*7c478bd9Sstevel@tonic-gate 			} else {
219*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
220*7c478bd9Sstevel@tonic-gate 			}
221*7c478bd9Sstevel@tonic-gate 			break;
222*7c478bd9Sstevel@tonic-gate 		case key_yp_config_tls_option:
223*7c478bd9Sstevel@tonic-gate 		case key_config_tls_option:
224*7c478bd9Sstevel@tonic-gate 			if (config_info->tls_method ==
225*7c478bd9Sstevel@tonic-gate 			    (tls_method_t)NO_VALUE_SET) {
226*7c478bd9Sstevel@tonic-gate 				if (same_string("none", attrib_val,
227*7c478bd9Sstevel@tonic-gate 						attrib_len))
228*7c478bd9Sstevel@tonic-gate 					config_info->tls_method = no_tls;
229*7c478bd9Sstevel@tonic-gate 				else if (same_string("ssl", attrib_val,
230*7c478bd9Sstevel@tonic-gate 						attrib_len))
231*7c478bd9Sstevel@tonic-gate 					config_info->tls_method = ssl_tls;
232*7c478bd9Sstevel@tonic-gate 				else
233*7c478bd9Sstevel@tonic-gate 					p_error = parse_bad_tls_option_error;
234*7c478bd9Sstevel@tonic-gate 			} else {
235*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
236*7c478bd9Sstevel@tonic-gate 			}
237*7c478bd9Sstevel@tonic-gate 			break;
238*7c478bd9Sstevel@tonic-gate 		case key_yp_config_tls_certificate_db:
239*7c478bd9Sstevel@tonic-gate 		case key_config_tls_certificate_db:
240*7c478bd9Sstevel@tonic-gate 			if (config_info->tls_cert_db == NULL) {
241*7c478bd9Sstevel@tonic-gate 				config_info->tls_cert_db =
242*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
243*7c478bd9Sstevel@tonic-gate 			} else {
244*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
245*7c478bd9Sstevel@tonic-gate 			}
246*7c478bd9Sstevel@tonic-gate 			break;
247*7c478bd9Sstevel@tonic-gate 		case key_yp_config_proxy_user:
248*7c478bd9Sstevel@tonic-gate 		case key_config_proxy_user:
249*7c478bd9Sstevel@tonic-gate 			if (config_info->proxy_dn == NULL) {
250*7c478bd9Sstevel@tonic-gate 				config_info->proxy_dn =
251*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
252*7c478bd9Sstevel@tonic-gate 			} else {
253*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
254*7c478bd9Sstevel@tonic-gate 			}
255*7c478bd9Sstevel@tonic-gate 			break;
256*7c478bd9Sstevel@tonic-gate 		case key_yp_config_proxy_passwd:
257*7c478bd9Sstevel@tonic-gate 		case key_config_proxy_passwd:
258*7c478bd9Sstevel@tonic-gate 			if (config_info->proxy_passwd == NULL) {
259*7c478bd9Sstevel@tonic-gate 				config_info->proxy_passwd =
260*7c478bd9Sstevel@tonic-gate 					s_strndup_esc(attrib_val, attrib_len);
261*7c478bd9Sstevel@tonic-gate 			} else {
262*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
263*7c478bd9Sstevel@tonic-gate 			}
264*7c478bd9Sstevel@tonic-gate 			break;
265*7c478bd9Sstevel@tonic-gate 		default:
266*7c478bd9Sstevel@tonic-gate 			p_error = parse_internal_error;
267*7c478bd9Sstevel@tonic-gate 			break;
268*7c478bd9Sstevel@tonic-gate 	}
269*7c478bd9Sstevel@tonic-gate 	return (p_error == no_parse_error ? 0 : -1);
270*7c478bd9Sstevel@tonic-gate }
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate /*
273*7c478bd9Sstevel@tonic-gate  * FUNCTION:	add_bind_attribute
274*7c478bd9Sstevel@tonic-gate  *
275*7c478bd9Sstevel@tonic-gate  *	Adds the attribute value to __nis_ldap_proxy_info
276*7c478bd9Sstevel@tonic-gate  *	if the value is not yet set.
277*7c478bd9Sstevel@tonic-gate  *
278*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	0 on success, -1 on failure
279*7c478bd9Sstevel@tonic-gate  *
280*7c478bd9Sstevel@tonic-gate  * INPUT:		attribute number and value (assumed to be non-NULL)
281*7c478bd9Sstevel@tonic-gate  */
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate int
add_bind_attribute(config_key attrib_num,const char * attrib_val,int attrib_len,__nis_ldap_proxy_info * proxy_info)284*7c478bd9Sstevel@tonic-gate add_bind_attribute(
285*7c478bd9Sstevel@tonic-gate 	config_key		attrib_num,
286*7c478bd9Sstevel@tonic-gate 	const char		*attrib_val,
287*7c478bd9Sstevel@tonic-gate 	int			attrib_len,
288*7c478bd9Sstevel@tonic-gate 	__nis_ldap_proxy_info	*proxy_info)
289*7c478bd9Sstevel@tonic-gate {
290*7c478bd9Sstevel@tonic-gate 	struct timeval	t;
291*7c478bd9Sstevel@tonic-gate 	int		limit;
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate 	switch (attrib_num) {
294*7c478bd9Sstevel@tonic-gate 		case key_yp_preferred_servers:
295*7c478bd9Sstevel@tonic-gate 		case key_preferred_servers:
296*7c478bd9Sstevel@tonic-gate 			if (proxy_info->default_servers == NULL) {
297*7c478bd9Sstevel@tonic-gate 				proxy_info->default_servers =
298*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
299*7c478bd9Sstevel@tonic-gate 			} else {
300*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
301*7c478bd9Sstevel@tonic-gate 			}
302*7c478bd9Sstevel@tonic-gate 			break;
303*7c478bd9Sstevel@tonic-gate 		case key_yp_auth_method:
304*7c478bd9Sstevel@tonic-gate 		case key_auth_method:
305*7c478bd9Sstevel@tonic-gate 			if (proxy_info->auth_method ==
306*7c478bd9Sstevel@tonic-gate 			    (auth_method_t)NO_VALUE_SET) {
307*7c478bd9Sstevel@tonic-gate 				if (same_string("none", attrib_val,
308*7c478bd9Sstevel@tonic-gate 						attrib_len))
309*7c478bd9Sstevel@tonic-gate 					proxy_info->auth_method = none;
310*7c478bd9Sstevel@tonic-gate 				else if (same_string("simple", attrib_val,
311*7c478bd9Sstevel@tonic-gate 						attrib_len))
312*7c478bd9Sstevel@tonic-gate 					proxy_info->auth_method = simple;
313*7c478bd9Sstevel@tonic-gate 				else if (same_string("sasl/cram-md5",
314*7c478bd9Sstevel@tonic-gate 						attrib_val, attrib_len))
315*7c478bd9Sstevel@tonic-gate 					proxy_info->auth_method = cram_md5;
316*7c478bd9Sstevel@tonic-gate 				else if (same_string("sasl/digest-md5",
317*7c478bd9Sstevel@tonic-gate 						attrib_val, attrib_len))
318*7c478bd9Sstevel@tonic-gate 					proxy_info->auth_method = digest_md5;
319*7c478bd9Sstevel@tonic-gate 				else
320*7c478bd9Sstevel@tonic-gate 					p_error = parse_bad_auth_method_error;
321*7c478bd9Sstevel@tonic-gate 			} else {
322*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
323*7c478bd9Sstevel@tonic-gate 			}
324*7c478bd9Sstevel@tonic-gate 			break;
325*7c478bd9Sstevel@tonic-gate 		case key_yp_tls_option:
326*7c478bd9Sstevel@tonic-gate 		case key_tls_option:
327*7c478bd9Sstevel@tonic-gate 			if (proxy_info->tls_method ==
328*7c478bd9Sstevel@tonic-gate 			    (tls_method_t)NO_VALUE_SET) {
329*7c478bd9Sstevel@tonic-gate 				if (same_string("none", attrib_val,
330*7c478bd9Sstevel@tonic-gate 						attrib_len))
331*7c478bd9Sstevel@tonic-gate 					proxy_info->tls_method = no_tls;
332*7c478bd9Sstevel@tonic-gate 				else if (same_string("ssl", attrib_val,
333*7c478bd9Sstevel@tonic-gate 						attrib_len))
334*7c478bd9Sstevel@tonic-gate 					proxy_info->tls_method = ssl_tls;
335*7c478bd9Sstevel@tonic-gate 				else
336*7c478bd9Sstevel@tonic-gate 					p_error = parse_bad_tls_option_error;
337*7c478bd9Sstevel@tonic-gate 			} else {
338*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
339*7c478bd9Sstevel@tonic-gate 			}
340*7c478bd9Sstevel@tonic-gate 			break;
341*7c478bd9Sstevel@tonic-gate 		case key_yp_tls_certificate_db:
342*7c478bd9Sstevel@tonic-gate 		case key_tls_certificate_db:
343*7c478bd9Sstevel@tonic-gate 			if (proxy_info->tls_cert_db == NULL) {
344*7c478bd9Sstevel@tonic-gate 				proxy_info->tls_cert_db =
345*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
346*7c478bd9Sstevel@tonic-gate 			} else {
347*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
348*7c478bd9Sstevel@tonic-gate 			}
349*7c478bd9Sstevel@tonic-gate 			break;
350*7c478bd9Sstevel@tonic-gate 		case key_yp_search_base:
351*7c478bd9Sstevel@tonic-gate 		case key_search_base:
352*7c478bd9Sstevel@tonic-gate 			if (proxy_info->default_search_base == NULL) {
353*7c478bd9Sstevel@tonic-gate 				if (!validate_dn(attrib_val, attrib_len))
354*7c478bd9Sstevel@tonic-gate 					break;
355*7c478bd9Sstevel@tonic-gate 				proxy_info->default_search_base =
356*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
357*7c478bd9Sstevel@tonic-gate 			} else {
358*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
359*7c478bd9Sstevel@tonic-gate 			}
360*7c478bd9Sstevel@tonic-gate 			break;
361*7c478bd9Sstevel@tonic-gate 		case key_yp_proxy_user:
362*7c478bd9Sstevel@tonic-gate 		case key_proxy_user:
363*7c478bd9Sstevel@tonic-gate 			if (proxy_info->proxy_dn == NULL) {
364*7c478bd9Sstevel@tonic-gate 				proxy_info->proxy_dn =
365*7c478bd9Sstevel@tonic-gate 					s_strndup(attrib_val, attrib_len);
366*7c478bd9Sstevel@tonic-gate 			} else {
367*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
368*7c478bd9Sstevel@tonic-gate 			}
369*7c478bd9Sstevel@tonic-gate 			break;
370*7c478bd9Sstevel@tonic-gate 		case key_yp_proxy_passwd:
371*7c478bd9Sstevel@tonic-gate 		case key_proxy_passwd:
372*7c478bd9Sstevel@tonic-gate 			if (proxy_info->proxy_passwd == NULL) {
373*7c478bd9Sstevel@tonic-gate 				proxy_info->proxy_passwd =
374*7c478bd9Sstevel@tonic-gate 					s_strndup_esc(attrib_val, attrib_len);
375*7c478bd9Sstevel@tonic-gate 			} else {
376*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
377*7c478bd9Sstevel@tonic-gate 			}
378*7c478bd9Sstevel@tonic-gate 			break;
379*7c478bd9Sstevel@tonic-gate 		case key_yp_ldap_base_domain:
380*7c478bd9Sstevel@tonic-gate 		case key_ldap_base_domain:
381*7c478bd9Sstevel@tonic-gate 			if (proxy_info->default_nis_domain == NULL) {
382*7c478bd9Sstevel@tonic-gate 				proxy_info->default_nis_domain =
383*7c478bd9Sstevel@tonic-gate 					s_strndup_esc(attrib_val, attrib_len);
384*7c478bd9Sstevel@tonic-gate 			} else {
385*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
386*7c478bd9Sstevel@tonic-gate 			}
387*7c478bd9Sstevel@tonic-gate 			break;
388*7c478bd9Sstevel@tonic-gate 		case key_yp_bind_timeout:
389*7c478bd9Sstevel@tonic-gate 		case key_bind_timeout:
390*7c478bd9Sstevel@tonic-gate 			if (proxy_info->bind_timeout.tv_sec ==
391*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
392*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
393*7c478bd9Sstevel@tonic-gate 						DEFAULT_BIND_TIMEOUT))
394*7c478bd9Sstevel@tonic-gate 					break;
395*7c478bd9Sstevel@tonic-gate 				proxy_info->bind_timeout = t;
396*7c478bd9Sstevel@tonic-gate 			} else {
397*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
398*7c478bd9Sstevel@tonic-gate 			}
399*7c478bd9Sstevel@tonic-gate 			break;
400*7c478bd9Sstevel@tonic-gate 		case key_yp_search_timeout:
401*7c478bd9Sstevel@tonic-gate 			if (proxy_info->search_timeout.tv_sec ==
402*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
403*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
404*7c478bd9Sstevel@tonic-gate 						DEFAULT_YP_SEARCH_TIMEOUT))
405*7c478bd9Sstevel@tonic-gate 					break;
406*7c478bd9Sstevel@tonic-gate 				proxy_info->search_timeout = t;
407*7c478bd9Sstevel@tonic-gate 			} else {
408*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
409*7c478bd9Sstevel@tonic-gate 			}
410*7c478bd9Sstevel@tonic-gate 			break;
411*7c478bd9Sstevel@tonic-gate 
412*7c478bd9Sstevel@tonic-gate 		case key_search_timeout:
413*7c478bd9Sstevel@tonic-gate 			if (proxy_info->search_timeout.tv_sec ==
414*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
415*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
416*7c478bd9Sstevel@tonic-gate 						DEFAULT_SEARCH_TIMEOUT))
417*7c478bd9Sstevel@tonic-gate 					break;
418*7c478bd9Sstevel@tonic-gate 				proxy_info->search_timeout = t;
419*7c478bd9Sstevel@tonic-gate 			} else {
420*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
421*7c478bd9Sstevel@tonic-gate 			}
422*7c478bd9Sstevel@tonic-gate 			break;
423*7c478bd9Sstevel@tonic-gate 		case key_yp_modify_timeout:
424*7c478bd9Sstevel@tonic-gate 		case key_modify_timeout:
425*7c478bd9Sstevel@tonic-gate 			if (proxy_info->modify_timeout.tv_sec ==
426*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
427*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
428*7c478bd9Sstevel@tonic-gate 						DEFAULT_MODIFY_TIMEOUT))
429*7c478bd9Sstevel@tonic-gate 					break;
430*7c478bd9Sstevel@tonic-gate 				proxy_info->modify_timeout = t;
431*7c478bd9Sstevel@tonic-gate 			} else {
432*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
433*7c478bd9Sstevel@tonic-gate 			}
434*7c478bd9Sstevel@tonic-gate 			break;
435*7c478bd9Sstevel@tonic-gate 		case key_yp_add_timeout:
436*7c478bd9Sstevel@tonic-gate 		case key_add_timeout:
437*7c478bd9Sstevel@tonic-gate 			if (proxy_info->add_timeout.tv_sec ==
438*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
439*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
440*7c478bd9Sstevel@tonic-gate 						DEFAULT_ADD_TIMEOUT))
441*7c478bd9Sstevel@tonic-gate 					break;
442*7c478bd9Sstevel@tonic-gate 				proxy_info->add_timeout = t;
443*7c478bd9Sstevel@tonic-gate 			} else {
444*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
445*7c478bd9Sstevel@tonic-gate 			}
446*7c478bd9Sstevel@tonic-gate 			break;
447*7c478bd9Sstevel@tonic-gate 		case key_yp_delete_timeout:
448*7c478bd9Sstevel@tonic-gate 		case key_delete_timeout:
449*7c478bd9Sstevel@tonic-gate 			if (proxy_info->delete_timeout.tv_sec ==
450*7c478bd9Sstevel@tonic-gate 			    (time_t)NO_VALUE_SET) {
451*7c478bd9Sstevel@tonic-gate 				if (!get_timeval_t(attrib_val, attrib_len, &t,
452*7c478bd9Sstevel@tonic-gate 						DEFAULT_DELETE_TIMEOUT))
453*7c478bd9Sstevel@tonic-gate 					break;
454*7c478bd9Sstevel@tonic-gate 				proxy_info->delete_timeout = t;
455*7c478bd9Sstevel@tonic-gate 			} else {
456*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
457*7c478bd9Sstevel@tonic-gate 			}
458*7c478bd9Sstevel@tonic-gate 			break;
459*7c478bd9Sstevel@tonic-gate 		case key_yp_search_time_limit:
460*7c478bd9Sstevel@tonic-gate 		case key_search_time_limit:
461*7c478bd9Sstevel@tonic-gate 			if (proxy_info->search_time_limit ==
462*7c478bd9Sstevel@tonic-gate 			    (int)NO_VALUE_SET) {
463*7c478bd9Sstevel@tonic-gate 				if (!get_limit(attrib_val, attrib_len, &limit,
464*7c478bd9Sstevel@tonic-gate 						DEFAULT_SEARCH_TIME_LIMIT))
465*7c478bd9Sstevel@tonic-gate 					break;
466*7c478bd9Sstevel@tonic-gate 				proxy_info->search_time_limit = limit;
467*7c478bd9Sstevel@tonic-gate 			} else {
468*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
469*7c478bd9Sstevel@tonic-gate 			}
470*7c478bd9Sstevel@tonic-gate 			break;
471*7c478bd9Sstevel@tonic-gate 		case key_yp_search_size_limit:
472*7c478bd9Sstevel@tonic-gate 		case key_search_size_limit:
473*7c478bd9Sstevel@tonic-gate 			if (proxy_info->search_size_limit ==
474*7c478bd9Sstevel@tonic-gate 			    (int)NO_VALUE_SET) {
475*7c478bd9Sstevel@tonic-gate 				if (!get_limit(attrib_val, attrib_len, &limit,
476*7c478bd9Sstevel@tonic-gate 						DEFAULT_SEARCH_SIZE_LIMIT))
477*7c478bd9Sstevel@tonic-gate 					break;
478*7c478bd9Sstevel@tonic-gate 				proxy_info->search_size_limit = limit;
479*7c478bd9Sstevel@tonic-gate 			} else {
480*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
481*7c478bd9Sstevel@tonic-gate 			}
482*7c478bd9Sstevel@tonic-gate 			break;
483*7c478bd9Sstevel@tonic-gate 		case key_yp_follow_referral:
484*7c478bd9Sstevel@tonic-gate 		case key_follow_referral:
485*7c478bd9Sstevel@tonic-gate 			if (proxy_info->follow_referral ==
486*7c478bd9Sstevel@tonic-gate 					(follow_referral_t)NO_VALUE_SET) {
487*7c478bd9Sstevel@tonic-gate 			    if (same_string("yes", attrib_val, attrib_len))
488*7c478bd9Sstevel@tonic-gate 				proxy_info->follow_referral = follow;
489*7c478bd9Sstevel@tonic-gate 			    else if (same_string("no", attrib_val, attrib_len))
490*7c478bd9Sstevel@tonic-gate 				proxy_info->follow_referral = no_follow;
491*7c478bd9Sstevel@tonic-gate 			    else
492*7c478bd9Sstevel@tonic-gate 				p_error = parse_yes_or_no_expected_error;
493*7c478bd9Sstevel@tonic-gate 			} else {
494*7c478bd9Sstevel@tonic-gate 				warn_duplicate_val(attrib_num);
495*7c478bd9Sstevel@tonic-gate 			}
496*7c478bd9Sstevel@tonic-gate 			break;
497*7c478bd9Sstevel@tonic-gate 		default:
498*7c478bd9Sstevel@tonic-gate 			p_error = parse_internal_error;
499*7c478bd9Sstevel@tonic-gate 			break;
500*7c478bd9Sstevel@tonic-gate 	}
501*7c478bd9Sstevel@tonic-gate 	return (p_error == no_parse_error ? 0 : -1);
502*7c478bd9Sstevel@tonic-gate }
503*7c478bd9Sstevel@tonic-gate 
504*7c478bd9Sstevel@tonic-gate /*
505*7c478bd9Sstevel@tonic-gate  * FUNCTION:	add_operation_attribute
506*7c478bd9Sstevel@tonic-gate  *
507*7c478bd9Sstevel@tonic-gate  *	Adds the attribute value to __nis_config_t and
508*7c478bd9Sstevel@tonic-gate  *	__nisdb_table_mapping_t if the value is not yet set.
509*7c478bd9Sstevel@tonic-gate  *
510*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	0 on success, -1 on failure
511*7c478bd9Sstevel@tonic-gate  *
512*7c478bd9Sstevel@tonic-gate  * INPUT:		attribute number and value (assumed to be non-NULL)
513*7c478bd9Sstevel@tonic-gate  */
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate int
add_operation_attribute(config_key attrib_num,const char * attrib_val,int attrib_len,__nis_config_t * config_info,__nisdb_table_mapping_t * table_info)516*7c478bd9Sstevel@tonic-gate add_operation_attribute(
517*7c478bd9Sstevel@tonic-gate 	config_key		attrib_num,
518*7c478bd9Sstevel@tonic-gate 	const char		*attrib_val,
519*7c478bd9Sstevel@tonic-gate 	int			attrib_len,
520*7c478bd9Sstevel@tonic-gate 	__nis_config_t		*config_info,
521*7c478bd9Sstevel@tonic-gate 	__nisdb_table_mapping_t	*table_info)
522*7c478bd9Sstevel@tonic-gate {
523*7c478bd9Sstevel@tonic-gate 	char	buf[1024];
524*7c478bd9Sstevel@tonic-gate 	int	i;
525*7c478bd9Sstevel@tonic-gate 	int	len;
526*7c478bd9Sstevel@tonic-gate 	time_t	timeout;
527*7c478bd9Sstevel@tonic-gate 	bool_t	last_digit = FALSE;
528*7c478bd9Sstevel@tonic-gate 
529*7c478bd9Sstevel@tonic-gate 	for (i = 0, len = 0; i < attrib_len; i++) {
530*7c478bd9Sstevel@tonic-gate 		if (!last_digit &&
531*7c478bd9Sstevel@tonic-gate 			is_whitespace(attrib_val[i]))
532*7c478bd9Sstevel@tonic-gate 				continue;
533*7c478bd9Sstevel@tonic-gate 		buf[len++] = attrib_val[i];
534*7c478bd9Sstevel@tonic-gate 		if (len >= sizeof (buf)) {
535*7c478bd9Sstevel@tonic-gate 			p_error = parse_line_too_long;
536*7c478bd9Sstevel@tonic-gate 			return (-1);
537*7c478bd9Sstevel@tonic-gate 		}
538*7c478bd9Sstevel@tonic-gate 		last_digit = isdigit(attrib_val[i]);
539*7c478bd9Sstevel@tonic-gate 	}
540*7c478bd9Sstevel@tonic-gate 	buf[len] = '\0';
541*7c478bd9Sstevel@tonic-gate 
542*7c478bd9Sstevel@tonic-gate 	switch (attrib_num) {
543*7c478bd9Sstevel@tonic-gate 	    case key_initial_update_action:
544*7c478bd9Sstevel@tonic-gate 		if (config_info->initialUpdate ==
545*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)NO_VALUE_SET) {
546*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("none", buf) == 0)
547*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = ini_none;
548*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("from_ldap", buf) == 0)
549*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate =
550*7c478bd9Sstevel@tonic-gate 				(__nis_initial_update_t)FROM_NO_INITIAL_UPDATE;
551*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("to_ldap", buf) == 0)
552*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate =
553*7c478bd9Sstevel@tonic-gate 				(__nis_initial_update_t)TO_NO_INITIAL_UPDATE;
554*7c478bd9Sstevel@tonic-gate 		    else
555*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_action_error;
556*7c478bd9Sstevel@tonic-gate 		} else if (config_info->initialUpdate ==
557*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)INITIAL_UPDATE_NO_ACTION) {
558*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("none", buf) == 0)
559*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = ini_none;
560*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("from_ldap", buf) == 0)
561*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = from_ldap_update_only;
562*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("to_ldap", buf) == 0)
563*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = to_ldap_update_only;
564*7c478bd9Sstevel@tonic-gate 		    else
565*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_action_error;
566*7c478bd9Sstevel@tonic-gate 		} else if (config_info->initialUpdate ==
567*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)NO_INITIAL_UPDATE_NO_ACTION) {
568*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("none", buf) == 0)
569*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = ini_none;
570*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("from_ldap", buf) == 0)
571*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = from_ldap;
572*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("to_ldap", buf) == 0)
573*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = to_ldap;
574*7c478bd9Sstevel@tonic-gate 		    else
575*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_action_error;
576*7c478bd9Sstevel@tonic-gate 		} else {
577*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
578*7c478bd9Sstevel@tonic-gate 		}
579*7c478bd9Sstevel@tonic-gate 		break;
580*7c478bd9Sstevel@tonic-gate 	    case key_initial_update_only:
581*7c478bd9Sstevel@tonic-gate 		if (config_info->initialUpdate ==
582*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)NO_VALUE_SET) {
583*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("yes", buf) == 0)
584*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate =
585*7c478bd9Sstevel@tonic-gate 				(__nis_initial_update_t)
586*7c478bd9Sstevel@tonic-gate 					INITIAL_UPDATE_NO_ACTION;
587*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("no", buf) == 0)
588*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate =
589*7c478bd9Sstevel@tonic-gate 				(__nis_initial_update_t)
590*7c478bd9Sstevel@tonic-gate 					NO_INITIAL_UPDATE_NO_ACTION;
591*7c478bd9Sstevel@tonic-gate 		    else
592*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_only_error;
593*7c478bd9Sstevel@tonic-gate 		} else if (config_info->initialUpdate ==
594*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)FROM_NO_INITIAL_UPDATE) {
595*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("yes", buf) == 0)
596*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = from_ldap_update_only;
597*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("no", buf) == 0)
598*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = from_ldap;
599*7c478bd9Sstevel@tonic-gate 		    else
600*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_only_error;
601*7c478bd9Sstevel@tonic-gate 		} else if (config_info->initialUpdate ==
602*7c478bd9Sstevel@tonic-gate 			(__nis_initial_update_t)TO_NO_INITIAL_UPDATE) {
603*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("yes", buf) == 0)
604*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = to_ldap_update_only;
605*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("no", buf) == 0)
606*7c478bd9Sstevel@tonic-gate 			    config_info->initialUpdate = to_ldap;
607*7c478bd9Sstevel@tonic-gate 		    else
608*7c478bd9Sstevel@tonic-gate 			p_error = parse_initial_update_only_error;
609*7c478bd9Sstevel@tonic-gate 		} else if (config_info->initialUpdate != ini_none) {
610*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
611*7c478bd9Sstevel@tonic-gate 		}
612*7c478bd9Sstevel@tonic-gate 		break;
613*7c478bd9Sstevel@tonic-gate 	    case key_thread_create_error_action:
614*7c478bd9Sstevel@tonic-gate 		if (config_info->threadCreationError ==
615*7c478bd9Sstevel@tonic-gate 			(__nis_thread_creation_error_t)NO_VALUE_SET) {
616*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("pass_error", buf) == 0)
617*7c478bd9Sstevel@tonic-gate 			    config_info->threadCreationError = pass_error;
618*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("retry", buf) == 0)
619*7c478bd9Sstevel@tonic-gate 			    config_info->threadCreationError = cre_retry;
620*7c478bd9Sstevel@tonic-gate 		    else
621*7c478bd9Sstevel@tonic-gate 			p_error = parse_thread_create_error_action_error;
622*7c478bd9Sstevel@tonic-gate 		} else {
623*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
624*7c478bd9Sstevel@tonic-gate 		}
625*7c478bd9Sstevel@tonic-gate 		break;
626*7c478bd9Sstevel@tonic-gate 	    case key_thread_create_error_attempts:
627*7c478bd9Sstevel@tonic-gate 		if (config_info->threadCreationErrorTimeout.attempts ==
628*7c478bd9Sstevel@tonic-gate 			NO_VALUE_SET) {
629*7c478bd9Sstevel@tonic-gate 		    if (get_int_val(buf, &i, DEFAULT_THREAD_ERROR_ATTEMPTS))
630*7c478bd9Sstevel@tonic-gate 			config_info->threadCreationErrorTimeout.attempts = i;
631*7c478bd9Sstevel@tonic-gate 		} else {
632*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
633*7c478bd9Sstevel@tonic-gate 		}
634*7c478bd9Sstevel@tonic-gate 		break;
635*7c478bd9Sstevel@tonic-gate 	    case key_thread_create_error_timeout:
636*7c478bd9Sstevel@tonic-gate 		if (config_info->threadCreationErrorTimeout.timeout ==
637*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
638*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout,
639*7c478bd9Sstevel@tonic-gate 				DEFAULT_THREAD_ERROR_TIME_OUT))
640*7c478bd9Sstevel@tonic-gate 			config_info->threadCreationErrorTimeout.timeout =
641*7c478bd9Sstevel@tonic-gate 				timeout;
642*7c478bd9Sstevel@tonic-gate 		} else {
643*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
644*7c478bd9Sstevel@tonic-gate 		}
645*7c478bd9Sstevel@tonic-gate 		break;
646*7c478bd9Sstevel@tonic-gate 	    case key_dump_error_action:
647*7c478bd9Sstevel@tonic-gate 		if (config_info->dumpError ==
648*7c478bd9Sstevel@tonic-gate 			(__nis_dump_error_t)NO_VALUE_SET) {
649*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("rollback", buf) == 0)
650*7c478bd9Sstevel@tonic-gate 			    config_info->dumpError = rollback;
651*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("retry", buf) == 0)
652*7c478bd9Sstevel@tonic-gate 			    config_info->dumpError = de_retry;
653*7c478bd9Sstevel@tonic-gate 		    else
654*7c478bd9Sstevel@tonic-gate 			p_error = parse_dump_error_action_error;
655*7c478bd9Sstevel@tonic-gate 		} else {
656*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
657*7c478bd9Sstevel@tonic-gate 		}
658*7c478bd9Sstevel@tonic-gate 		break;
659*7c478bd9Sstevel@tonic-gate 	    case key_dump_error_attempts:
660*7c478bd9Sstevel@tonic-gate 		if (config_info->dumpErrorTimeout.attempts == NO_VALUE_SET) {
661*7c478bd9Sstevel@tonic-gate 		    if (get_int_val(buf, &i, DEFAULT_DUMP_ERROR_ATTEMPTS))
662*7c478bd9Sstevel@tonic-gate 			config_info->dumpErrorTimeout.attempts = i;
663*7c478bd9Sstevel@tonic-gate 		} else {
664*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
665*7c478bd9Sstevel@tonic-gate 		}
666*7c478bd9Sstevel@tonic-gate 		break;
667*7c478bd9Sstevel@tonic-gate 	    case key_dump_error_timeout:
668*7c478bd9Sstevel@tonic-gate 		if (config_info->dumpErrorTimeout.timeout ==
669*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
670*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout,
671*7c478bd9Sstevel@tonic-gate 				DEFAULT_DUMP_ERROR_TIME_OUT))
672*7c478bd9Sstevel@tonic-gate 			config_info->dumpErrorTimeout.timeout = timeout;
673*7c478bd9Sstevel@tonic-gate 		} else {
674*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
675*7c478bd9Sstevel@tonic-gate 		}
676*7c478bd9Sstevel@tonic-gate 		break;
677*7c478bd9Sstevel@tonic-gate 	    case key_resync:
678*7c478bd9Sstevel@tonic-gate 		if (config_info->resyncService ==
679*7c478bd9Sstevel@tonic-gate 			(__nis_resync_service_t)NO_VALUE_SET) {
680*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("directory_locked", buf) == 0)
681*7c478bd9Sstevel@tonic-gate 			    config_info->resyncService = directory_locked;
682*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("from_copy", buf) == 0)
683*7c478bd9Sstevel@tonic-gate 			    config_info->resyncService = from_copy;
684*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("from_live", buf) == 0)
685*7c478bd9Sstevel@tonic-gate 			    config_info->resyncService = from_live;
686*7c478bd9Sstevel@tonic-gate 		    else
687*7c478bd9Sstevel@tonic-gate 			p_error = parse_resync_error;
688*7c478bd9Sstevel@tonic-gate 		} else {
689*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
690*7c478bd9Sstevel@tonic-gate 		}
691*7c478bd9Sstevel@tonic-gate 		break;
692*7c478bd9Sstevel@tonic-gate 	    case key_update_batching:
693*7c478bd9Sstevel@tonic-gate 		if (config_info->updateBatching ==
694*7c478bd9Sstevel@tonic-gate 			(__nis_update_batching_t)NO_VALUE_SET) {
695*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("none", buf) == 0)
696*7c478bd9Sstevel@tonic-gate 			    config_info->updateBatching = upd_none;
697*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("accumulate", buf) == 0) {
698*7c478bd9Sstevel@tonic-gate 			    config_info->updateBatching = accumulate;
699*7c478bd9Sstevel@tonic-gate 		    } else if (strcasecmp("bounded_accumulate", buf) == 0) {
700*7c478bd9Sstevel@tonic-gate 			    config_info->updateBatching = bounded_accumulate;
701*7c478bd9Sstevel@tonic-gate 		    } else
702*7c478bd9Sstevel@tonic-gate 			p_error = parse_update_batching_error;
703*7c478bd9Sstevel@tonic-gate 		} else {
704*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
705*7c478bd9Sstevel@tonic-gate 		}
706*7c478bd9Sstevel@tonic-gate 		break;
707*7c478bd9Sstevel@tonic-gate 	    case key_update_batching_timeout:
708*7c478bd9Sstevel@tonic-gate 		if (config_info->updateBatchingTimeout.timeout ==
709*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
710*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout, DEFAULT_BATCHING_TIME_OUT))
711*7c478bd9Sstevel@tonic-gate 			config_info->updateBatchingTimeout.timeout = timeout;
712*7c478bd9Sstevel@tonic-gate 		} else {
713*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
714*7c478bd9Sstevel@tonic-gate 		}
715*7c478bd9Sstevel@tonic-gate 		break;
716*7c478bd9Sstevel@tonic-gate 	    case key_number_threads:
717*7c478bd9Sstevel@tonic-gate 		if (config_info->numberOfServiceThreads ==
718*7c478bd9Sstevel@tonic-gate 			(int)NO_VALUE_SET) {
719*7c478bd9Sstevel@tonic-gate 		    if (get_uint_val(buf, &i, DEFAULT_NUMBER_OF_THREADS))
720*7c478bd9Sstevel@tonic-gate 			    config_info->numberOfServiceThreads = i;
721*7c478bd9Sstevel@tonic-gate 		} else {
722*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
723*7c478bd9Sstevel@tonic-gate 		}
724*7c478bd9Sstevel@tonic-gate 		break;
725*7c478bd9Sstevel@tonic-gate 	    case key_yp_emulation:
726*7c478bd9Sstevel@tonic-gate 		if (config_info->emulate_yp ==
727*7c478bd9Sstevel@tonic-gate 			(int)NO_VALUE_SET) {
728*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("yes", buf) == 0)
729*7c478bd9Sstevel@tonic-gate 			    config_info->emulate_yp = TRUE;
730*7c478bd9Sstevel@tonic-gate 		} else {
731*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
732*7c478bd9Sstevel@tonic-gate 		}
733*7c478bd9Sstevel@tonic-gate 		break;
734*7c478bd9Sstevel@tonic-gate 		case key_yp_retrieve_error_action:
735*7c478bd9Sstevel@tonic-gate 		if (table_info->retrieveError ==
736*7c478bd9Sstevel@tonic-gate 			(__nis_retrieve_error_t)NO_VALUE_SET) {
737*7c478bd9Sstevel@tonic-gate 			if (strcasecmp("use_cached", buf) == 0)
738*7c478bd9Sstevel@tonic-gate 				table_info->retrieveError = use_cached;
739*7c478bd9Sstevel@tonic-gate 			else if (strcasecmp("fail", buf) == 0)
740*7c478bd9Sstevel@tonic-gate 				table_info->retrieveError = fail;
741*7c478bd9Sstevel@tonic-gate 			else
742*7c478bd9Sstevel@tonic-gate 		p_error = parse_yp_retrieve_error_action_error;
743*7c478bd9Sstevel@tonic-gate 		} else {
744*7c478bd9Sstevel@tonic-gate 			warn_duplicate_val(attrib_num);
745*7c478bd9Sstevel@tonic-gate 		}
746*7c478bd9Sstevel@tonic-gate 		break;
747*7c478bd9Sstevel@tonic-gate 	    case key_retrieve_error_action:
748*7c478bd9Sstevel@tonic-gate 		if (table_info->retrieveError ==
749*7c478bd9Sstevel@tonic-gate 			(__nis_retrieve_error_t)NO_VALUE_SET) {
750*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("use_cached", buf) == 0)
751*7c478bd9Sstevel@tonic-gate 			    table_info->retrieveError = use_cached;
752*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("try_again", buf) == 0)
753*7c478bd9Sstevel@tonic-gate 			    table_info->retrieveError = try_again;
754*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("unavail", buf) == 0)
755*7c478bd9Sstevel@tonic-gate 			    table_info->retrieveError = ret_unavail;
756*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("no_such_name", buf) == 0)
757*7c478bd9Sstevel@tonic-gate 			    table_info->retrieveError = no_such_name;
758*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("retry", buf) == 0)
759*7c478bd9Sstevel@tonic-gate 			    table_info->retrieveError = ret_retry;
760*7c478bd9Sstevel@tonic-gate 		    else
761*7c478bd9Sstevel@tonic-gate 			p_error = parse_retrieve_error_action_error;
762*7c478bd9Sstevel@tonic-gate 		} else {
763*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
764*7c478bd9Sstevel@tonic-gate 		}
765*7c478bd9Sstevel@tonic-gate 		break;
766*7c478bd9Sstevel@tonic-gate 		case key_yp_retrieve_error_attempts:
767*7c478bd9Sstevel@tonic-gate 	    case key_retrieve_error_attempts:
768*7c478bd9Sstevel@tonic-gate 		if (table_info->retrieveErrorRetry.attempts == NO_VALUE_SET) {
769*7c478bd9Sstevel@tonic-gate 		    if (get_int_val(buf, &i, DEFAULT_RETRIEVE_ERROR_ATTEMPTS))
770*7c478bd9Sstevel@tonic-gate 			table_info->retrieveErrorRetry.attempts = i;
771*7c478bd9Sstevel@tonic-gate 		} else {
772*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
773*7c478bd9Sstevel@tonic-gate 		}
774*7c478bd9Sstevel@tonic-gate 		break;
775*7c478bd9Sstevel@tonic-gate 		case key_yp_retreive_error_timeout:
776*7c478bd9Sstevel@tonic-gate 	    case key_retreive_error_timeout:
777*7c478bd9Sstevel@tonic-gate 		if (table_info->retrieveErrorRetry.timeout ==
778*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
779*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout,
780*7c478bd9Sstevel@tonic-gate 				DEFAULT_RETRIEVE_ERROR_TIME_OUT))
781*7c478bd9Sstevel@tonic-gate 			table_info->retrieveErrorRetry.timeout = timeout;
782*7c478bd9Sstevel@tonic-gate 		} else {
783*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
784*7c478bd9Sstevel@tonic-gate 		}
785*7c478bd9Sstevel@tonic-gate 		break;
786*7c478bd9Sstevel@tonic-gate 		case key_yp_store_error_action:
787*7c478bd9Sstevel@tonic-gate 		if (table_info->storeError ==
788*7c478bd9Sstevel@tonic-gate 			(__nis_store_error_t)NO_VALUE_SET) {
789*7c478bd9Sstevel@tonic-gate 			if (strcasecmp("retry", buf) == 0)
790*7c478bd9Sstevel@tonic-gate 				table_info->storeError = sto_retry;
791*7c478bd9Sstevel@tonic-gate 			else if (strcasecmp("fail", buf) == 0)
792*7c478bd9Sstevel@tonic-gate 				table_info->storeError = sto_fail;
793*7c478bd9Sstevel@tonic-gate 			else
794*7c478bd9Sstevel@tonic-gate 			p_error = parse_yp_store_error_action_error;
795*7c478bd9Sstevel@tonic-gate 		} else {
796*7c478bd9Sstevel@tonic-gate 			warn_duplicate_val(attrib_num);
797*7c478bd9Sstevel@tonic-gate 		}
798*7c478bd9Sstevel@tonic-gate 		break;
799*7c478bd9Sstevel@tonic-gate 	    case key_store_error_action:
800*7c478bd9Sstevel@tonic-gate 		if (table_info->storeError ==
801*7c478bd9Sstevel@tonic-gate 			(__nis_store_error_t)NO_VALUE_SET) {
802*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("system_error", buf) == 0)
803*7c478bd9Sstevel@tonic-gate 			    table_info->storeError = system_error;
804*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("unavail", buf) == 0)
805*7c478bd9Sstevel@tonic-gate 			    table_info->storeError = sto_unavail;
806*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("retry", buf) == 0)
807*7c478bd9Sstevel@tonic-gate 			    table_info->storeError = sto_retry;
808*7c478bd9Sstevel@tonic-gate 		    else
809*7c478bd9Sstevel@tonic-gate 			p_error = parse_store_error_action_error;
810*7c478bd9Sstevel@tonic-gate 		} else {
811*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
812*7c478bd9Sstevel@tonic-gate 		}
813*7c478bd9Sstevel@tonic-gate 		break;
814*7c478bd9Sstevel@tonic-gate 		case key_yp_store_error_attempts:
815*7c478bd9Sstevel@tonic-gate 	    case key_store_error_attempts:
816*7c478bd9Sstevel@tonic-gate 		if (table_info->storeErrorRetry.attempts == NO_VALUE_SET) {
817*7c478bd9Sstevel@tonic-gate 		    if (get_int_val(buf, &i,
818*7c478bd9Sstevel@tonic-gate 				DEFAULT_STORE_ERROR_ATTEMPTS))
819*7c478bd9Sstevel@tonic-gate 			table_info->storeErrorRetry.attempts = i;
820*7c478bd9Sstevel@tonic-gate 		} else {
821*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
822*7c478bd9Sstevel@tonic-gate 		}
823*7c478bd9Sstevel@tonic-gate 		break;
824*7c478bd9Sstevel@tonic-gate 		case key_yp_store_error_timeout:
825*7c478bd9Sstevel@tonic-gate 	    case key_store_error_timeout:
826*7c478bd9Sstevel@tonic-gate 		if (table_info->storeErrorRetry.timeout ==
827*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
828*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout,
829*7c478bd9Sstevel@tonic-gate 				DEFAULT_STORE_ERROR_TIME_OUT))
830*7c478bd9Sstevel@tonic-gate 			table_info->storeErrorRetry.timeout = timeout;
831*7c478bd9Sstevel@tonic-gate 		} else {
832*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
833*7c478bd9Sstevel@tonic-gate 		}
834*7c478bd9Sstevel@tonic-gate 		break;
835*7c478bd9Sstevel@tonic-gate 	    case key_refresh_error_action:
836*7c478bd9Sstevel@tonic-gate 		if (table_info->refreshError ==
837*7c478bd9Sstevel@tonic-gate 			(__nis_refresh_error_t)NO_VALUE_SET) {
838*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("continue_using", buf) == 0)
839*7c478bd9Sstevel@tonic-gate 			    table_info->refreshError = continue_using;
840*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("cache_expired", buf) == 0)
841*7c478bd9Sstevel@tonic-gate 			    table_info->refreshError = cache_expired;
842*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("tryagain", buf) == 0)
843*7c478bd9Sstevel@tonic-gate 			    table_info->refreshError = tryagain;
844*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("retry", buf) == 0)
845*7c478bd9Sstevel@tonic-gate 			    table_info->refreshError = ref_retry;
846*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("continue_using,retry", buf) == 0 ||
847*7c478bd9Sstevel@tonic-gate 			strcasecmp("retry,continue_using", buf) == 0)
848*7c478bd9Sstevel@tonic-gate 			    table_info->refreshError = continue_using_retry;
849*7c478bd9Sstevel@tonic-gate 		    else
850*7c478bd9Sstevel@tonic-gate 			p_error = parse_refresh_error_action_error;
851*7c478bd9Sstevel@tonic-gate 		} else {
852*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
853*7c478bd9Sstevel@tonic-gate 		}
854*7c478bd9Sstevel@tonic-gate 		break;
855*7c478bd9Sstevel@tonic-gate 	    case key_refresh_error_attempts:
856*7c478bd9Sstevel@tonic-gate 		if (table_info->refreshErrorRetry.attempts == NO_VALUE_SET) {
857*7c478bd9Sstevel@tonic-gate 		    if (get_int_val(buf, &i, DEFAULT_REFRESH_ERROR_ATTEMPTS))
858*7c478bd9Sstevel@tonic-gate 			table_info->refreshErrorRetry.attempts = i;
859*7c478bd9Sstevel@tonic-gate 		} else {
860*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
861*7c478bd9Sstevel@tonic-gate 		}
862*7c478bd9Sstevel@tonic-gate 		break;
863*7c478bd9Sstevel@tonic-gate 	    case key_refresh_error_timeout:
864*7c478bd9Sstevel@tonic-gate 		if (table_info->refreshErrorRetry.timeout ==
865*7c478bd9Sstevel@tonic-gate 			(time_t)NO_VALUE_SET) {
866*7c478bd9Sstevel@tonic-gate 		    if (get_time_t(buf, &timeout,
867*7c478bd9Sstevel@tonic-gate 				DEFAULT_REFRESH_ERROR_TIME_OUT))
868*7c478bd9Sstevel@tonic-gate 			table_info->refreshErrorRetry.timeout = timeout;
869*7c478bd9Sstevel@tonic-gate 		} else {
870*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
871*7c478bd9Sstevel@tonic-gate 		}
872*7c478bd9Sstevel@tonic-gate 		break;
873*7c478bd9Sstevel@tonic-gate 		case key_yp_match_fetch:
874*7c478bd9Sstevel@tonic-gate 	    case key_match_fetch:
875*7c478bd9Sstevel@tonic-gate 		if (table_info->matchFetch ==
876*7c478bd9Sstevel@tonic-gate 			(__nis_match_fetch_t)NO_VALUE_SET) {
877*7c478bd9Sstevel@tonic-gate 		    if (strcasecmp("no_match_only", buf) == 0)
878*7c478bd9Sstevel@tonic-gate 			    table_info->matchFetch = no_match_only;
879*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("always", buf) == 0)
880*7c478bd9Sstevel@tonic-gate 			    table_info->matchFetch = mat_always;
881*7c478bd9Sstevel@tonic-gate 		    else if (strcasecmp("never", buf) == 0)
882*7c478bd9Sstevel@tonic-gate 			    table_info->matchFetch = mat_never;
883*7c478bd9Sstevel@tonic-gate 		    else
884*7c478bd9Sstevel@tonic-gate 			p_error = parse_match_fetch_error;
885*7c478bd9Sstevel@tonic-gate 		} else {
886*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
887*7c478bd9Sstevel@tonic-gate 		}
888*7c478bd9Sstevel@tonic-gate 		break;
889*7c478bd9Sstevel@tonic-gate 	    case key_max_rpc_recsize:
890*7c478bd9Sstevel@tonic-gate 		if (config_info->maxRPCRecordSize ==
891*7c478bd9Sstevel@tonic-gate 			(int)NO_VALUE_SET) {
892*7c478bd9Sstevel@tonic-gate 		    if (get_uint_val(buf, &i, RPC_MAXDATASIZE))
893*7c478bd9Sstevel@tonic-gate 			    config_info->maxRPCRecordSize = i;
894*7c478bd9Sstevel@tonic-gate 		} else {
895*7c478bd9Sstevel@tonic-gate 		    warn_duplicate_val(attrib_num);
896*7c478bd9Sstevel@tonic-gate 		}
897*7c478bd9Sstevel@tonic-gate 		break;
898*7c478bd9Sstevel@tonic-gate 	    default:
899*7c478bd9Sstevel@tonic-gate 		p_error = parse_internal_error;
900*7c478bd9Sstevel@tonic-gate 		break;
901*7c478bd9Sstevel@tonic-gate 	}
902*7c478bd9Sstevel@tonic-gate 
903*7c478bd9Sstevel@tonic-gate 	return (p_error == no_parse_error ? 0 : -1);
904*7c478bd9Sstevel@tonic-gate }
905*7c478bd9Sstevel@tonic-gate 
906*7c478bd9Sstevel@tonic-gate /*
907*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_attrib_num
908*7c478bd9Sstevel@tonic-gate  *
909*7c478bd9Sstevel@tonic-gate  *	Get the attribute number for the corresponding keyword.
910*7c478bd9Sstevel@tonic-gate  *
911*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	attribute number on success,
912*7c478bd9Sstevel@tonic-gate  *			key_bad on failure
913*7c478bd9Sstevel@tonic-gate  *
914*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute name string (assumed to be non-NULL)
915*7c478bd9Sstevel@tonic-gate  */
916*7c478bd9Sstevel@tonic-gate 
917*7c478bd9Sstevel@tonic-gate config_key
get_attrib_num(const char * s,int n)918*7c478bd9Sstevel@tonic-gate get_attrib_num(const char *s, int n)
919*7c478bd9Sstevel@tonic-gate {
920*7c478bd9Sstevel@tonic-gate 	int		k;
921*7c478bd9Sstevel@tonic-gate 	int		i;
922*7c478bd9Sstevel@tonic-gate 	config_key	attrib_num = key_bad;
923*7c478bd9Sstevel@tonic-gate 
924*7c478bd9Sstevel@tonic-gate 	k = n < sizeof (_key_val) ? n : sizeof (_key_val) - 1;
925*7c478bd9Sstevel@tonic-gate 	(void) memcpy(_key_val, s, k);
926*7c478bd9Sstevel@tonic-gate 	_key_val[k] = '\0';
927*7c478bd9Sstevel@tonic-gate 
928*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (keyword_lookup) /
929*7c478bd9Sstevel@tonic-gate 			sizeof (keyword_lookup[0]); i++) {
930*7c478bd9Sstevel@tonic-gate 		if (strncasecmp(s, keyword_lookup[i].key_name, n) == 0 &&
931*7c478bd9Sstevel@tonic-gate 				strlen(keyword_lookup[i].key_name) == n) {
932*7c478bd9Sstevel@tonic-gate 			attrib_num = keyword_lookup[i].key_id;
933*7c478bd9Sstevel@tonic-gate 			break;
934*7c478bd9Sstevel@tonic-gate 		}
935*7c478bd9Sstevel@tonic-gate 	}
936*7c478bd9Sstevel@tonic-gate 
937*7c478bd9Sstevel@tonic-gate 	if (attrib_num == key_bad) {
938*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_key;
939*7c478bd9Sstevel@tonic-gate 	}
940*7c478bd9Sstevel@tonic-gate 
941*7c478bd9Sstevel@tonic-gate 	return (attrib_num);
942*7c478bd9Sstevel@tonic-gate }
943*7c478bd9Sstevel@tonic-gate 
944*7c478bd9Sstevel@tonic-gate /*
945*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_timeval_t
946*7c478bd9Sstevel@tonic-gate  *
947*7c478bd9Sstevel@tonic-gate  *	Extract time from string
948*7c478bd9Sstevel@tonic-gate  *
949*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	TRUE if parsed
950*7c478bd9Sstevel@tonic-gate  *			FALSE otherwise
951*7c478bd9Sstevel@tonic-gate  *
952*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute value string (assumed to be non-NULL)
953*7c478bd9Sstevel@tonic-gate  */
954*7c478bd9Sstevel@tonic-gate 
955*7c478bd9Sstevel@tonic-gate static bool_t
get_timeval_t(const char * s,int len,struct timeval * t,time_t default_val)956*7c478bd9Sstevel@tonic-gate get_timeval_t(
957*7c478bd9Sstevel@tonic-gate 	const char	*s,
958*7c478bd9Sstevel@tonic-gate 	int		len,
959*7c478bd9Sstevel@tonic-gate 	struct timeval	*t,
960*7c478bd9Sstevel@tonic-gate 	time_t		default_val)
961*7c478bd9Sstevel@tonic-gate {
962*7c478bd9Sstevel@tonic-gate 	time_t		tv_sec		= 0;
963*7c478bd9Sstevel@tonic-gate 	time_t		tv_usec		= 0;
964*7c478bd9Sstevel@tonic-gate 	time_t		digit;
965*7c478bd9Sstevel@tonic-gate 	time_t		mult		= 100000;
966*7c478bd9Sstevel@tonic-gate 	bool_t		got_digit	= FALSE;
967*7c478bd9Sstevel@tonic-gate 	bool_t		got_period	= FALSE;
968*7c478bd9Sstevel@tonic-gate 	const char	*s_end		= s + len;
969*7c478bd9Sstevel@tonic-gate 
970*7c478bd9Sstevel@tonic-gate 	while (s < s_end && is_whitespace(*s))
971*7c478bd9Sstevel@tonic-gate 		s++;
972*7c478bd9Sstevel@tonic-gate 
973*7c478bd9Sstevel@tonic-gate 	while (s < s_end && isdigit(*s)) {
974*7c478bd9Sstevel@tonic-gate 		digit = (*s++) - '0';
975*7c478bd9Sstevel@tonic-gate 		got_digit = TRUE;
976*7c478bd9Sstevel@tonic-gate 		if (WILL_OVERFLOW_TIME(tv_sec, digit))
977*7c478bd9Sstevel@tonic-gate 			tv_sec = TIME_MAX;
978*7c478bd9Sstevel@tonic-gate 		else
979*7c478bd9Sstevel@tonic-gate 			tv_sec = tv_sec * 10 + digit;
980*7c478bd9Sstevel@tonic-gate 	}
981*7c478bd9Sstevel@tonic-gate 	while (s < s_end && is_whitespace(*s))
982*7c478bd9Sstevel@tonic-gate 		s++;
983*7c478bd9Sstevel@tonic-gate 
984*7c478bd9Sstevel@tonic-gate 	if (s < s_end && *s == PERIOD_CHAR) {
985*7c478bd9Sstevel@tonic-gate 		s++;
986*7c478bd9Sstevel@tonic-gate 		got_period = TRUE;
987*7c478bd9Sstevel@tonic-gate 		while (s < s_end && isdigit(*s)) {
988*7c478bd9Sstevel@tonic-gate 			got_digit = TRUE;
989*7c478bd9Sstevel@tonic-gate 			digit = (*s++) - '0';
990*7c478bd9Sstevel@tonic-gate 			tv_usec += digit * mult;
991*7c478bd9Sstevel@tonic-gate 			mult /= 10;
992*7c478bd9Sstevel@tonic-gate 		}
993*7c478bd9Sstevel@tonic-gate 		while (s < s_end && is_whitespace(*s))
994*7c478bd9Sstevel@tonic-gate 			s++;
995*7c478bd9Sstevel@tonic-gate 	}
996*7c478bd9Sstevel@tonic-gate 	if (s == s_end) {
997*7c478bd9Sstevel@tonic-gate 		if (!got_digit) {
998*7c478bd9Sstevel@tonic-gate 			if (got_period) {
999*7c478bd9Sstevel@tonic-gate 				p_error = parse_bad_time_error;
1000*7c478bd9Sstevel@tonic-gate 				return (FALSE);
1001*7c478bd9Sstevel@tonic-gate 			}
1002*7c478bd9Sstevel@tonic-gate 			tv_sec = default_val;
1003*7c478bd9Sstevel@tonic-gate 		}
1004*7c478bd9Sstevel@tonic-gate 		t->tv_sec = tv_sec;
1005*7c478bd9Sstevel@tonic-gate 		t->tv_usec = tv_usec;
1006*7c478bd9Sstevel@tonic-gate 	} else
1007*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_time_error;
1008*7c478bd9Sstevel@tonic-gate 
1009*7c478bd9Sstevel@tonic-gate 	return (s == s_end);
1010*7c478bd9Sstevel@tonic-gate }
1011*7c478bd9Sstevel@tonic-gate 
1012*7c478bd9Sstevel@tonic-gate /*
1013*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_limit
1014*7c478bd9Sstevel@tonic-gate  *
1015*7c478bd9Sstevel@tonic-gate  *	Extract limit from string
1016*7c478bd9Sstevel@tonic-gate  *
1017*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	TRUE if parsed
1018*7c478bd9Sstevel@tonic-gate  *			FALSE otherwise
1019*7c478bd9Sstevel@tonic-gate  *
1020*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute value string (assumed to be non-NULL)
1021*7c478bd9Sstevel@tonic-gate  */
1022*7c478bd9Sstevel@tonic-gate 
1023*7c478bd9Sstevel@tonic-gate 
1024*7c478bd9Sstevel@tonic-gate static bool_t
get_limit(const char * s,int len,int * limit,int default_val)1025*7c478bd9Sstevel@tonic-gate get_limit(
1026*7c478bd9Sstevel@tonic-gate 	const char	*s,
1027*7c478bd9Sstevel@tonic-gate 	int		len,
1028*7c478bd9Sstevel@tonic-gate 	int		*limit,
1029*7c478bd9Sstevel@tonic-gate 	int		default_val)
1030*7c478bd9Sstevel@tonic-gate {
1031*7c478bd9Sstevel@tonic-gate 	bool_t		got_digit	= FALSE;
1032*7c478bd9Sstevel@tonic-gate 	int		l		= 0;
1033*7c478bd9Sstevel@tonic-gate 	time_t		digit;
1034*7c478bd9Sstevel@tonic-gate 	const char	*s_end		= s + len;
1035*7c478bd9Sstevel@tonic-gate 
1036*7c478bd9Sstevel@tonic-gate 	while (s < s_end && is_whitespace(*s))
1037*7c478bd9Sstevel@tonic-gate 		s++;
1038*7c478bd9Sstevel@tonic-gate 
1039*7c478bd9Sstevel@tonic-gate 	while (s < s_end && isdigit(*s)) {
1040*7c478bd9Sstevel@tonic-gate 		got_digit = TRUE;
1041*7c478bd9Sstevel@tonic-gate 		digit = (*s++) - '0';
1042*7c478bd9Sstevel@tonic-gate 		if (WILL_OVERFLOW_LIMIT(l, digit))
1043*7c478bd9Sstevel@tonic-gate 			l = LIMIT_MAX;
1044*7c478bd9Sstevel@tonic-gate 		else
1045*7c478bd9Sstevel@tonic-gate 			l = l * 10 + digit;
1046*7c478bd9Sstevel@tonic-gate 	}
1047*7c478bd9Sstevel@tonic-gate 	while (s < s_end && is_whitespace(*s))
1048*7c478bd9Sstevel@tonic-gate 		s++;
1049*7c478bd9Sstevel@tonic-gate 	if (s == s_end) {
1050*7c478bd9Sstevel@tonic-gate 		if (!got_digit)
1051*7c478bd9Sstevel@tonic-gate 			l = default_val;
1052*7c478bd9Sstevel@tonic-gate 		*limit = l;
1053*7c478bd9Sstevel@tonic-gate 	} else
1054*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_uint_error;
1055*7c478bd9Sstevel@tonic-gate 
1056*7c478bd9Sstevel@tonic-gate 	return (s == s_end);
1057*7c478bd9Sstevel@tonic-gate }
1058*7c478bd9Sstevel@tonic-gate 
1059*7c478bd9Sstevel@tonic-gate /*
1060*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_time_t
1061*7c478bd9Sstevel@tonic-gate  *
1062*7c478bd9Sstevel@tonic-gate  *	Parse a buffer containing a time_t string
1063*7c478bd9Sstevel@tonic-gate  *
1064*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	TRUE on success, FALSE on failure
1065*7c478bd9Sstevel@tonic-gate  *
1066*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute value string (assumed to be non-NULL)
1067*7c478bd9Sstevel@tonic-gate  */
1068*7c478bd9Sstevel@tonic-gate 
1069*7c478bd9Sstevel@tonic-gate static bool_t
get_time_t(const char * s,time_t * t,time_t default_val)1070*7c478bd9Sstevel@tonic-gate get_time_t(const char *s, time_t *t, time_t default_val)
1071*7c478bd9Sstevel@tonic-gate {
1072*7c478bd9Sstevel@tonic-gate 	bool_t	got_digit	= FALSE;
1073*7c478bd9Sstevel@tonic-gate 	time_t	timeout		= 0;
1074*7c478bd9Sstevel@tonic-gate 
1075*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1076*7c478bd9Sstevel@tonic-gate 		;
1077*7c478bd9Sstevel@tonic-gate 	while (isdigit(*s)) {
1078*7c478bd9Sstevel@tonic-gate 		got_digit = TRUE;
1079*7c478bd9Sstevel@tonic-gate 		if (WILL_OVERFLOW_TIME(timeout, *s))
1080*7c478bd9Sstevel@tonic-gate 			timeout = TIME_MAX;
1081*7c478bd9Sstevel@tonic-gate 		else
1082*7c478bd9Sstevel@tonic-gate 			timeout = timeout * 10 + *s - '0';
1083*7c478bd9Sstevel@tonic-gate 		s++;
1084*7c478bd9Sstevel@tonic-gate 	}
1085*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1086*7c478bd9Sstevel@tonic-gate 		;
1087*7c478bd9Sstevel@tonic-gate 	if (*s != '\0') {
1088*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_int_error;
1089*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1090*7c478bd9Sstevel@tonic-gate 	}
1091*7c478bd9Sstevel@tonic-gate 	if (!got_digit)
1092*7c478bd9Sstevel@tonic-gate 		timeout = default_val;
1093*7c478bd9Sstevel@tonic-gate 
1094*7c478bd9Sstevel@tonic-gate 	*t = timeout;
1095*7c478bd9Sstevel@tonic-gate 	return (TRUE);
1096*7c478bd9Sstevel@tonic-gate }
1097*7c478bd9Sstevel@tonic-gate 
1098*7c478bd9Sstevel@tonic-gate /*
1099*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_uint_val
1100*7c478bd9Sstevel@tonic-gate  *
1101*7c478bd9Sstevel@tonic-gate  *	Parse a buffer containing a non-negative integer
1102*7c478bd9Sstevel@tonic-gate  *
1103*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	TRUE on success, FALSE on failure
1104*7c478bd9Sstevel@tonic-gate  *
1105*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute value string (assumed to be non-NULL)
1106*7c478bd9Sstevel@tonic-gate  */
1107*7c478bd9Sstevel@tonic-gate 
1108*7c478bd9Sstevel@tonic-gate static bool_t
get_uint_val(const char * s,int * val,int default_val)1109*7c478bd9Sstevel@tonic-gate get_uint_val(const char *s, int *val, int default_val)
1110*7c478bd9Sstevel@tonic-gate {
1111*7c478bd9Sstevel@tonic-gate 	bool_t	got_digit	= FALSE;
1112*7c478bd9Sstevel@tonic-gate 	int	v		= 0;
1113*7c478bd9Sstevel@tonic-gate 
1114*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1115*7c478bd9Sstevel@tonic-gate 		;
1116*7c478bd9Sstevel@tonic-gate 	while (isdigit(*s)) {
1117*7c478bd9Sstevel@tonic-gate 		got_digit = TRUE;
1118*7c478bd9Sstevel@tonic-gate 		if (WILL_OVERFLOW_INT(v, *s))
1119*7c478bd9Sstevel@tonic-gate 			v = INT_MAX;
1120*7c478bd9Sstevel@tonic-gate 		else
1121*7c478bd9Sstevel@tonic-gate 			v = v * 10 + *s - '0';
1122*7c478bd9Sstevel@tonic-gate 		s++;
1123*7c478bd9Sstevel@tonic-gate 	}
1124*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1125*7c478bd9Sstevel@tonic-gate 		;
1126*7c478bd9Sstevel@tonic-gate 	if (*s != '\0') {
1127*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_int_error;
1128*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1129*7c478bd9Sstevel@tonic-gate 	}
1130*7c478bd9Sstevel@tonic-gate 
1131*7c478bd9Sstevel@tonic-gate 	if (!got_digit)
1132*7c478bd9Sstevel@tonic-gate 		v = default_val;
1133*7c478bd9Sstevel@tonic-gate 
1134*7c478bd9Sstevel@tonic-gate 	*val = v;
1135*7c478bd9Sstevel@tonic-gate 	return (TRUE);
1136*7c478bd9Sstevel@tonic-gate }
1137*7c478bd9Sstevel@tonic-gate 
1138*7c478bd9Sstevel@tonic-gate /*
1139*7c478bd9Sstevel@tonic-gate  * FUNCTION:	get_int_val
1140*7c478bd9Sstevel@tonic-gate  *
1141*7c478bd9Sstevel@tonic-gate  *	Parse a buffer containing a non-negative integer
1142*7c478bd9Sstevel@tonic-gate  *
1143*7c478bd9Sstevel@tonic-gate  * RETURN VALUE:	TRUE on success, FALSE on failure
1144*7c478bd9Sstevel@tonic-gate  *
1145*7c478bd9Sstevel@tonic-gate  * INPUT:		the attribute value string (assumed to be non-NULL)
1146*7c478bd9Sstevel@tonic-gate  */
1147*7c478bd9Sstevel@tonic-gate 
1148*7c478bd9Sstevel@tonic-gate static bool_t
get_int_val(const char * s,int * val,int default_val)1149*7c478bd9Sstevel@tonic-gate get_int_val(const char *s, int *val, int default_val)
1150*7c478bd9Sstevel@tonic-gate {
1151*7c478bd9Sstevel@tonic-gate 	bool_t	got_digit	= FALSE;
1152*7c478bd9Sstevel@tonic-gate 	int	v		= 0;
1153*7c478bd9Sstevel@tonic-gate 	bool_t	is_neg		= FALSE;
1154*7c478bd9Sstevel@tonic-gate 
1155*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1156*7c478bd9Sstevel@tonic-gate 		;
1157*7c478bd9Sstevel@tonic-gate 	if (*s == '-') {
1158*7c478bd9Sstevel@tonic-gate 		is_neg = TRUE;
1159*7c478bd9Sstevel@tonic-gate 		s++;
1160*7c478bd9Sstevel@tonic-gate 	}
1161*7c478bd9Sstevel@tonic-gate 	while (isdigit(*s)) {
1162*7c478bd9Sstevel@tonic-gate 		got_digit = TRUE;
1163*7c478bd9Sstevel@tonic-gate 		if (WILL_OVERFLOW_INT(v, *s))
1164*7c478bd9Sstevel@tonic-gate 			v = INT_MAX;
1165*7c478bd9Sstevel@tonic-gate 		else
1166*7c478bd9Sstevel@tonic-gate 			v = v * 10 + *s - '0';
1167*7c478bd9Sstevel@tonic-gate 		s++;
1168*7c478bd9Sstevel@tonic-gate 	}
1169*7c478bd9Sstevel@tonic-gate 	for (; is_whitespace(*s); s++)
1170*7c478bd9Sstevel@tonic-gate 		;
1171*7c478bd9Sstevel@tonic-gate 	if (*s != '\0') {
1172*7c478bd9Sstevel@tonic-gate 		p_error = parse_bad_int_error;
1173*7c478bd9Sstevel@tonic-gate 		return (FALSE);
1174*7c478bd9Sstevel@tonic-gate 	}
1175*7c478bd9Sstevel@tonic-gate 
1176*7c478bd9Sstevel@tonic-gate 	if (!got_digit) {
1177*7c478bd9Sstevel@tonic-gate 		if (is_neg) {
1178*7c478bd9Sstevel@tonic-gate 			p_error = parse_bad_int_error;
1179*7c478bd9Sstevel@tonic-gate 			return (FALSE);
1180*7c478bd9Sstevel@tonic-gate 		}
1181*7c478bd9Sstevel@tonic-gate 		v = default_val;
1182*7c478bd9Sstevel@tonic-gate 	}
1183*7c478bd9Sstevel@tonic-gate 	if (is_neg)
1184*7c478bd9Sstevel@tonic-gate 		v = -v;
1185*7c478bd9Sstevel@tonic-gate 	*val = v;
1186*7c478bd9Sstevel@tonic-gate 	return (TRUE);
1187*7c478bd9Sstevel@tonic-gate }
1188*7c478bd9Sstevel@tonic-gate 
1189*7c478bd9Sstevel@tonic-gate static void
warn_duplicate_val(config_key attrib_num)1190*7c478bd9Sstevel@tonic-gate warn_duplicate_val(
1191*7c478bd9Sstevel@tonic-gate 	config_key attrib_num)
1192*7c478bd9Sstevel@tonic-gate {
1193*7c478bd9Sstevel@tonic-gate 	const char	*key_name = "Unknown";
1194*7c478bd9Sstevel@tonic-gate 	int		i;
1195*7c478bd9Sstevel@tonic-gate 
1196*7c478bd9Sstevel@tonic-gate 	if (warn_file == NULL || is_cmd_line_option(attrib_num))
1197*7c478bd9Sstevel@tonic-gate 		return;
1198*7c478bd9Sstevel@tonic-gate 
1199*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (keyword_lookup) /
1200*7c478bd9Sstevel@tonic-gate 			sizeof (keyword_lookup[0]); i++) {
1201*7c478bd9Sstevel@tonic-gate 		if (attrib_num == keyword_lookup[i].key_id) {
1202*7c478bd9Sstevel@tonic-gate 			key_name = keyword_lookup[i].key_name;
1203*7c478bd9Sstevel@tonic-gate 			break;
1204*7c478bd9Sstevel@tonic-gate 		}
1205*7c478bd9Sstevel@tonic-gate 	}
1206*7c478bd9Sstevel@tonic-gate 	if (cons != NULL) {
1207*7c478bd9Sstevel@tonic-gate 		fprintf(cons,
1208*7c478bd9Sstevel@tonic-gate 		"Warning: Duplicate value for %s in %s at line:%d\n",
1209*7c478bd9Sstevel@tonic-gate 			key_name, warn_file, start_line_num);
1210*7c478bd9Sstevel@tonic-gate 	} else {
1211*7c478bd9Sstevel@tonic-gate 		syslog(LOG_INFO,
1212*7c478bd9Sstevel@tonic-gate 			"Duplicate value for %s in %s at line:%d",
1213*7c478bd9Sstevel@tonic-gate 			key_name, warn_file, start_line_num);
1214*7c478bd9Sstevel@tonic-gate 	}
1215*7c478bd9Sstevel@tonic-gate }
1216*7c478bd9Sstevel@tonic-gate 
1217*7c478bd9Sstevel@tonic-gate void
warn_duplicate_map(const char * db_id,config_key attrib_num)1218*7c478bd9Sstevel@tonic-gate warn_duplicate_map(
1219*7c478bd9Sstevel@tonic-gate 	const char *db_id,
1220*7c478bd9Sstevel@tonic-gate 	config_key attrib_num)
1221*7c478bd9Sstevel@tonic-gate {
1222*7c478bd9Sstevel@tonic-gate 	const char	*key_name = "Unknown";
1223*7c478bd9Sstevel@tonic-gate 	int		i;
1224*7c478bd9Sstevel@tonic-gate 
1225*7c478bd9Sstevel@tonic-gate 	if (warn_file == NULL)
1226*7c478bd9Sstevel@tonic-gate 		return;
1227*7c478bd9Sstevel@tonic-gate 
1228*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (keyword_lookup) /
1229*7c478bd9Sstevel@tonic-gate 			sizeof (keyword_lookup[0]); i++) {
1230*7c478bd9Sstevel@tonic-gate 		if (attrib_num == keyword_lookup[i].key_id) {
1231*7c478bd9Sstevel@tonic-gate 			key_name = keyword_lookup[i].key_name;
1232*7c478bd9Sstevel@tonic-gate 			break;
1233*7c478bd9Sstevel@tonic-gate 		}
1234*7c478bd9Sstevel@tonic-gate 	}
1235*7c478bd9Sstevel@tonic-gate 	if (cons != NULL) {
1236*7c478bd9Sstevel@tonic-gate 		fprintf(cons,
1237*7c478bd9Sstevel@tonic-gate 		"Warning: Duplicate value for %s:%s in %s at line:%d\n",
1238*7c478bd9Sstevel@tonic-gate 			key_name, db_id, warn_file, start_line_num);
1239*7c478bd9Sstevel@tonic-gate 	} else {
1240*7c478bd9Sstevel@tonic-gate 		syslog(LOG_INFO,
1241*7c478bd9Sstevel@tonic-gate 			"Duplicate value for %s:%s in %s at line:%d",
1242*7c478bd9Sstevel@tonic-gate 			key_name, db_id, warn_file, start_line_num);
1243*7c478bd9Sstevel@tonic-gate 	}
1244*7c478bd9Sstevel@tonic-gate }
1245