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