/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <locale.h>
#include <lber.h>
#include <ldap.h>
#include <syslog.h>
#include "ldap_parse.h"
#include "nis_parse_ldap_conf.h"
static struct {
const char *key_name;
} keyword_lookup[] = {
{RESYNC, key_resync},
};
/*
* FUNCTION: add_config_attribute
*
* Adds the attribute value to __nis_config_info_t
* if the value is not yet set.
*
* RETURN VALUE: 0 on success, -1 on failure
*
* INPUT: attribute number and value (assumed to be non-NULL)
*/
int
const char *attrib_val,
int attrib_len,
{
switch (attrib_num) {
case key_yp_config_dn:
case key_config_dn:
break;
} else {
}
break;
case key_config_server_list:
} else {
}
break;
case key_config_auth_method:
if (config_info->auth_method ==
else if (same_string("sasl/cram-md5",
else if (same_string("sasl/digest-md5",
else
} else {
}
break;
case key_yp_config_tls_option:
case key_config_tls_option:
if (config_info->tls_method ==
else
} else {
}
break;
} else {
}
break;
case key_yp_config_proxy_user:
case key_config_proxy_user:
} else {
}
break;
case key_config_proxy_passwd:
} else {
}
break;
default:
break;
}
}
/*
* FUNCTION: add_bind_attribute
*
* Adds the attribute value to __nis_ldap_proxy_info
* if the value is not yet set.
*
* RETURN VALUE: 0 on success, -1 on failure
*
* INPUT: attribute number and value (assumed to be non-NULL)
*/
int
const char *attrib_val,
int attrib_len,
{
struct timeval t;
int limit;
switch (attrib_num) {
case key_yp_preferred_servers:
case key_preferred_servers:
} else {
}
break;
case key_yp_auth_method:
case key_auth_method:
if (proxy_info->auth_method ==
else if (same_string("sasl/cram-md5",
else if (same_string("sasl/digest-md5",
else
} else {
}
break;
case key_yp_tls_option:
case key_tls_option:
if (proxy_info->tls_method ==
else
} else {
}
break;
case key_tls_certificate_db:
} else {
}
break;
case key_yp_search_base:
case key_search_base:
break;
} else {
}
break;
case key_yp_proxy_user:
case key_proxy_user:
} else {
}
break;
case key_yp_proxy_passwd:
case key_proxy_passwd:
} else {
}
break;
case key_yp_ldap_base_domain:
case key_ldap_base_domain:
} else {
}
break;
case key_yp_bind_timeout:
case key_bind_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->bind_timeout = t;
} else {
}
break;
case key_yp_search_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->search_timeout = t;
} else {
}
break;
case key_search_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->search_timeout = t;
} else {
}
break;
case key_yp_modify_timeout:
case key_modify_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->modify_timeout = t;
} else {
}
break;
case key_yp_add_timeout:
case key_add_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->add_timeout = t;
} else {
}
break;
case key_yp_delete_timeout:
case key_delete_timeout:
(time_t)NO_VALUE_SET) {
break;
proxy_info->delete_timeout = t;
} else {
}
break;
case key_yp_search_time_limit:
case key_search_time_limit:
if (proxy_info->search_time_limit ==
(int)NO_VALUE_SET) {
break;
} else {
}
break;
case key_yp_search_size_limit:
case key_search_size_limit:
if (proxy_info->search_size_limit ==
(int)NO_VALUE_SET) {
break;
} else {
}
break;
case key_yp_follow_referral:
case key_follow_referral:
if (proxy_info->follow_referral ==
else
} else {
}
break;
default:
break;
}
}
/*
* FUNCTION: add_operation_attribute
*
* Adds the attribute value to __nis_config_t and
* __nisdb_table_mapping_t if the value is not yet set.
*
* RETURN VALUE: 0 on success, -1 on failure
*
* INPUT: attribute number and value (assumed to be non-NULL)
*/
int
const char *attrib_val,
int attrib_len,
{
int i;
int len;
for (i = 0, len = 0; i < attrib_len; i++) {
if (!last_digit &&
is_whitespace(attrib_val[i]))
continue;
return (-1);
}
}
switch (attrib_num) {
if (config_info->initialUpdate ==
else
} else if (config_info->initialUpdate ==
else
} else if (config_info->initialUpdate ==
else
} else {
}
break;
case key_initial_update_only:
if (config_info->initialUpdate ==
else
} else if (config_info->initialUpdate ==
else
} else if (config_info->initialUpdate ==
else
}
break;
if (config_info->threadCreationError ==
else
} else {
}
break;
NO_VALUE_SET) {
} else {
}
break;
(time_t)NO_VALUE_SET) {
} else {
}
break;
case key_dump_error_action:
if (config_info->dumpError ==
else
} else {
}
break;
case key_dump_error_attempts:
} else {
}
break;
case key_dump_error_timeout:
(time_t)NO_VALUE_SET) {
} else {
}
break;
case key_resync:
if (config_info->resyncService ==
else
} else {
}
break;
case key_update_batching:
if (config_info->updateBatching ==
} else
} else {
}
break;
(time_t)NO_VALUE_SET) {
} else {
}
break;
case key_number_threads:
if (config_info->numberOfServiceThreads ==
(int)NO_VALUE_SET) {
} else {
}
break;
case key_yp_emulation:
if (config_info->emulate_yp ==
(int)NO_VALUE_SET) {
} else {
}
break;
if (table_info->retrieveError ==
else
} else {
}
break;
if (table_info->retrieveError ==
else
} else {
}
break;
} else {
}
break;
(time_t)NO_VALUE_SET) {
} else {
}
break;
if (table_info->storeError ==
else
} else {
}
break;
case key_store_error_action:
if (table_info->storeError ==
else
} else {
}
break;
case key_store_error_attempts:
if (get_int_val(buf, &i,
} else {
}
break;
case key_store_error_timeout:
(time_t)NO_VALUE_SET) {
} else {
}
break;
case key_refresh_error_action:
if (table_info->refreshError ==
else
} else {
}
break;
} else {
}
break;
(time_t)NO_VALUE_SET) {
} else {
}
break;
case key_yp_match_fetch:
case key_match_fetch:
if (table_info->matchFetch ==
else
} else {
}
break;
case key_max_rpc_recsize:
if (config_info->maxRPCRecordSize ==
(int)NO_VALUE_SET) {
config_info->maxRPCRecordSize = i;
} else {
}
break;
default:
break;
}
}
/*
* FUNCTION: get_attrib_num
*
* Get the attribute number for the corresponding keyword.
*
* RETURN VALUE: attribute number on success,
* key_bad on failure
*
* INPUT: the attribute name string (assumed to be non-NULL)
*/
get_attrib_num(const char *s, int n)
{
int k;
int i;
_key_val[k] = '\0';
for (i = 0; i < sizeof (keyword_lookup) /
sizeof (keyword_lookup[0]); i++) {
break;
}
}
if (attrib_num == key_bad) {
}
return (attrib_num);
}
/*
* FUNCTION: get_timeval_t
*
* Extract time from string
*
* RETURN VALUE: TRUE if parsed
* FALSE otherwise
*
* INPUT: the attribute value string (assumed to be non-NULL)
*/
static bool_t
const char *s,
int len,
struct timeval *t,
{
while (s < s_end && is_whitespace(*s))
s++;
digit = (*s++) - '0';
else
}
while (s < s_end && is_whitespace(*s))
s++;
if (s < s_end && *s == PERIOD_CHAR) {
s++;
got_period = TRUE;
digit = (*s++) - '0';
mult /= 10;
}
while (s < s_end && is_whitespace(*s))
s++;
}
if (s == s_end) {
if (!got_digit) {
if (got_period) {
return (FALSE);
}
}
} else
return (s == s_end);
}
/*
* FUNCTION: get_limit
*
* Extract limit from string
*
* RETURN VALUE: TRUE if parsed
* FALSE otherwise
*
* INPUT: the attribute value string (assumed to be non-NULL)
*/
static bool_t
const char *s,
int len,
int *limit,
int default_val)
{
int l = 0;
while (s < s_end && is_whitespace(*s))
s++;
digit = (*s++) - '0';
if (WILL_OVERFLOW_LIMIT(l, digit))
l = LIMIT_MAX;
else
l = l * 10 + digit;
}
while (s < s_end && is_whitespace(*s))
s++;
if (s == s_end) {
if (!got_digit)
l = default_val;
*limit = l;
} else
return (s == s_end);
}
/*
* FUNCTION: get_time_t
*
* Parse a buffer containing a time_t string
*
* RETURN VALUE: TRUE on success, FALSE on failure
*
* INPUT: the attribute value string (assumed to be non-NULL)
*/
static bool_t
{
for (; is_whitespace(*s); s++)
;
while (isdigit(*s)) {
if (WILL_OVERFLOW_TIME(timeout, *s))
else
s++;
}
for (; is_whitespace(*s); s++)
;
if (*s != '\0') {
return (FALSE);
}
if (!got_digit)
*t = timeout;
return (TRUE);
}
/*
* FUNCTION: get_uint_val
*
* Parse a buffer containing a non-negative integer
*
* RETURN VALUE: TRUE on success, FALSE on failure
*
* INPUT: the attribute value string (assumed to be non-NULL)
*/
static bool_t
{
int v = 0;
for (; is_whitespace(*s); s++)
;
while (isdigit(*s)) {
if (WILL_OVERFLOW_INT(v, *s))
v = INT_MAX;
else
v = v * 10 + *s - '0';
s++;
}
for (; is_whitespace(*s); s++)
;
if (*s != '\0') {
return (FALSE);
}
if (!got_digit)
v = default_val;
*val = v;
return (TRUE);
}
/*
* FUNCTION: get_int_val
*
* Parse a buffer containing a non-negative integer
*
* RETURN VALUE: TRUE on success, FALSE on failure
*
* INPUT: the attribute value string (assumed to be non-NULL)
*/
static bool_t
{
int v = 0;
for (; is_whitespace(*s); s++)
;
if (*s == '-') {
s++;
}
while (isdigit(*s)) {
if (WILL_OVERFLOW_INT(v, *s))
v = INT_MAX;
else
v = v * 10 + *s - '0';
s++;
}
for (; is_whitespace(*s); s++)
;
if (*s != '\0') {
return (FALSE);
}
if (!got_digit) {
if (is_neg) {
return (FALSE);
}
v = default_val;
}
if (is_neg)
v = -v;
*val = v;
return (TRUE);
}
static void
{
int i;
return;
for (i = 0; i < sizeof (keyword_lookup) /
sizeof (keyword_lookup[0]); i++) {
break;
}
}
"Warning: Duplicate value for %s in %s at line:%d\n",
} else {
"Duplicate value for %s in %s at line:%d",
}
}
void
const char *db_id,
{
int i;
return;
for (i = 0; i < sizeof (keyword_lookup) /
sizeof (keyword_lookup[0]); i++) {
break;
}
}
"Warning: Duplicate value for %s:%s in %s at line:%d\n",
} else {
"Duplicate value for %s:%s in %s at line:%d",
}
}