/*
* 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 2015 Gary Mills
* Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <locale.h>
#include "ldap_parse.h"
#include "nis_parse_ldap_conf.h"
#include "nis_parse_ldap_yp_util.h"
#include "nis_parse_ldap_util.h"
/* other attribute functions */
static void get_mapping_rule(const char *s, int len,
/* mapping rule functions */
static const char *get_lhs_match(const char *s, const char *end_s,
static const char *get_lhs_paren_item(const char *s, const char *end_s,
static const char *get_mapping_item(const char *s, const char *end_s,
static const char *get_print_mapping_element(const char *s,
static const char *get_subElement(const char *s, const char *end_s,
extern __yp_domain_context_t ypDomains;
/*
* FUNCTION: add_mapping_attribute
*
* Adds the attribute value to __nis_table_mapping_t
* if the value is not yet set for the given database.
*
* RETURN VALUE: 0 on success, -1 on failure
*
* INPUT: attribute number and value
*/
int
const char *attrib_val,
int attrib_len,
{
const char *s;
const char *attrib_end;
const char *db_id_end;
const char *begin_token;
char *index_string;
int nm;
char *tmp_dbId;
for (s = attrib_val; s < attrib_end; s++)
if (*s == COLON_CHAR)
break;
return (-1);
}
db_id_end = s;
s--;
if (s == attrib_val) {
return (-1);
}
if (yp2ldap) {
return (-1);
}
/* domain explicitly specified */
/*
* No logging is needed here, as
* check_domain_specific_order
* will log any appropriate errors.
*/
if (nm != 0) {
return (-1);
}
}
}
/* No mapping with this id, create one */
return (-1);
}
(void) initialize_table_mapping(t_mapping);
/* dbId is the label before the colon */
return (-1);
}
new_mapping = TRUE;
} else {
/* a table mapping already exists, use it */
new_mapping = FALSE;
}
s = db_id_end + 1;
while (s < attrib_end && is_whitespace(*s))
s++;
switch (attrib_num) {
case key_yp_map_flags:
if (t_mapping->usedns_flag != 0 ||
t_mapping->securemap_flag != 0) {
break;
}
while (is_whitespace(*s) && s < attrib_end)
s++;
while (s < attrib_end) {
if (s < attrib_end && *s == 'b')
if (s < attrib_end && *s == 's')
s++;
}
break;
case key_yp_comment_char:
if (t_mapping->commentChar !=
break;
}
while (is_whitespace(*s) && s < attrib_end)
s++;
(s+2) <= attrib_end) {
attrib_end--;
while (*s != SINGLE_QUOTE_CHAR)
s++;
if (*s == SINGLE_QUOTE_CHAR &&
*(s+2) == SINGLE_QUOTE_CHAR) {
} else if (*s == SINGLE_QUOTE_CHAR &&
*(s+1) == SINGLE_QUOTE_CHAR) {
} else {
/* anything else is an error */
}
break;
} else {
break;
}
while (s < attrib_end && is_whitespace(*s))
s++;
if (s < attrib_end) {
attrib_end--;
while (s < attrib_end &&
*s != DOUBLE_QUOTE_CHAR)
s++;
s++;
begin_token = s;
while (s < attrib_end &&
*s != DOUBLE_QUOTE_CHAR) {
if (*s == ESCAPE_CHAR)
s++;
s++;
}
break;
} else {
}
break;
case key_yp_name_fields:
case key_yp_split_field:
break;
}
}
break;
case key_yp_db_id_map:
case key_db_id_map:
break;
}
if (s < attrib_end && *s == OPEN_BRACKET) {
if (index_string == NULL)
break;
(void) parse_index(index_string,
if (p_error != no_parse_error)
break;
}
while (is_whitespace(*s) && s < attrib_end)
s++;
if (s < attrib_end) {
attrib_end--;
s_strndup_esc(s, attrib_end - s);
} else {
if (yp2ldap) {
} else {
}
}
break;
case key_yp_entry_ttl:
case key_entry_ttl:
break;
}
break;
case key_yp_ldap_object_dn:
case key_ldap_object_dn:
break;
}
break;
break;
case key_nis_to_ldap_map:
case key_nisplus_to_ldap_map:
if (t_mapping->ruleToLDAP != 0) {
break;
}
break;
case key_ldap_to_nis_map:
case key_ldap_to_nisplus_map:
break;
}
break;
default:
break;
}
if (p_error == no_parse_error) {
if (new_mapping) {
if (*table_mapping == NULL)
else {
t = t->next)
;
}
}
} else {
if (new_mapping)
}
}
/*
* FUNCTION: add_ypdomains_attribute
*
* Adds the yp domains information to the __yp_domain_context_t
* structure.
*
* RETURN: 0 on success, -1 on failure
*
* INPUT: attribute number and value
*/
int
const char *attrib_val,
int attrib_len,
{
const char *s;
const char *attrib_end;
int numDomains = 0;
for (s = attrib_val; s < attrib_end; s++) {
if (*s == COLON_CHAR) {
break;
}
}
s--;
if (s == attrib_val) {
return (-1);
}
/*
* No point allocating. We cant return the resulting structure,
* so just return failure. Should not ever happen because we
* are always called with a pointer to the global ypDomains
* structure.
*/
return (-1);
}
switch (attrib_num) {
case key_yp_domain_context:
(numDomains + 1) *
sizeof (ypDomains->domainLabels[0]));
break;
}
break;
}
while (s < attrib_end && is_whitespace(*s))
s++;
if (*s == COLON_CHAR)
s++;
while (s < attrib_end && is_whitespace(*s))
s++;
(numDomains + 1) *
break;
}
if (s < attrib_end) {
attrib_end--;
s_strndup_esc(s, attrib_end - s);
break;
}
} else {
ypDomains->numDomains--;
}
break;
case key_yppasswdd_domains:
(char **)s_realloc(
sizeof (ypDomains->yppasswddDomainLabels[0]));
break;
}
[ypDomains->numYppasswdd] =
}
break;
}
}
/*
* FUNCTION: get_ttls
*
* Parse time to live attribute
*
* RETURN VALUE: TRUE on success, FALSE on failure
*
* INPUT: the attribute value
*/
static bool_t
const char *s,
const char *s_end,
{
/*
* attribute should be of the form
* initialTTLlo ":" initialTTLhi ":" runningTTL
*/
if (s == s_end) {
return (FALSE);
}
if (isdigit(*s)) {
digit = (*s++) - '0';
else
}
} else {
}
while (s < s_end && is_whitespace(*s))
s++;
return (FALSE);
}
while (s < s_end && is_whitespace(*s))
s++;
if (isdigit(*s)) {
digit = (*s++) - '0';
else
}
} else {
}
while (s < s_end && is_whitespace(*s))
s++;
if (s >= s_end || *s++ != COLON_CHAR) {
return (FALSE);
}
while (s < s_end && is_whitespace(*s))
s++;
if (isdigit(*s)) {
digit = (*s++) - '0';
else
}
} else {
}
while (s < s_end && is_whitespace(*s))
s++;
if (s != s_end) {
return (FALSE);
}
return (TRUE);
}
/*
* FUNCTION: parse_name_fields
*
* Parse yp name fields
*
* RETURN VALUE: 0 on success, non-zero on failure
*
* INPUTS: attrib_value and attribute_end pointers.
*/
static int
const char *name_s_end,
{
int i, n = 0;
int nElements = 0;
int numSplits = 0;
int itm_count = 0;
const char *begin_fmt;
const char *end_fmt;
const char *begin_token;
const char *end_token;
t_map->numColumns = 0;
for (; parse_next_line > 0; parse_next_line--) {
nElements = 0;
name_s++;
if (name_s == name_s_end) {
return (1);
}
name_s++;
if (name_s == name_s_end) {
return (1);
}
name_s++;
if (name_s == name_s_end) {
return (1);
}
if (fmt_string == NULL) {
return (2);
}
fmt_string = NULL;
return (3);
}
fmt_string = NULL;
!= mmt_berstring) {
continue;
}
name_s++;
name_s++; /* now at comma char */
name_s++;
begin_token = name_s++;
return (4);
}
if (token != string_token) {
return (5);
}
(nElements + 1) *
sizeof (__nis_mapping_item_t));
return (2);
}
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (4);
}
nElements++;
}
if (p_error != no_parse_error) {
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (6);
}
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (4);
}
name_s++;
if (*name_s == COMMA_CHAR)
if (nElements == 0) {
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (7);
}
(numSplits + 1) *
sizeof (__nis_mapping_element_t));
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (2);
}
n = t_map->numColumns;
if (!add_column(t_map,
return (1);
itm_count++;
} else {
for (n = 0; n < (nElements + 1); n++)
free_mapping_item(&item[n]);
return (1);
}
}
numSplits++;
}
for (n = 0; n < t_map->numColumns; n++) {
free_mapping_item(&item[n]);
}
}
}
/*
* FUNCTION: parse_object_dn
*
* Parse object dn attribute
*
* RETURN VALUE: __nis_object_dn_t on success
* NULL on failure
*
* INPUT: the attribute value
*/
static __nis_object_dn_t *
{
const char *s_begin;
const char *s_end;
/*
* The attribute should be of form
* objectDN *( ";" objectDN )
* objectDN = readObjectSpec [":"[writeObjectSpec]]
* readObjectSpec = [baseAndScope [filterAttrValList]]
* writeObjectSpec = [baseAndScope [attrValList [":" deleteDisp]]]
*/
while (s < end) {
s_begin = s;
if (s == NULL)
break;
else
if (token == dn_no_token)
break;
}
next = (__nis_object_dn_t *)
break;
}
if (token == dn_semi_token)
continue;
switch (dn_state) {
case dn_begin_parse:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else {
break;
}
break;
case dn_got_read_dn:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else
break;
case dn_got_read_q_scope:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else if (token == dn_base_token) {
} else if (token == dn_one_token) {
} else if (token == dn_sub_token) {
} else {
}
break;
case dn_got_read_scope:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else
break;
case dn_got_read_q_filter:
if (token == dn_ques_token) {
} else if (token == dn_colon_token) {
} else {
break;
}
break;
case dn_got_read_filter:
if (token == dn_ques_token) {
} else if (token == dn_colon_token) {
} else
break;
case dn_got_write_colon:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else {
break;
}
break;
case dn_got_write_dn:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else
break;
case dn_got_write_q_scope:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else if (token == dn_base_token) {
} else if (token == dn_one_token) {
} else if (token == dn_sub_token) {
} else {
}
break;
case dn_got_write_scope:
if (token == dn_ques_token)
else if (token == dn_colon_token) {
} else
break;
case dn_got_write_q_filter:
if (token == dn_ques_token) {
} else if (token == dn_colon_token) {
} else {
break;
}
break;
case dn_got_write_filter:
if (token == dn_ques_token) {
} else if (token == dn_colon_token) {
} else
break;
case dn_got_delete_colon:
if (token == dn_ques_token) {
} else if (token == dn_colon_token) {
} else {
break;
}
break;
case dn_got_delete_dsp:
break;
}
if (p_error != no_parse_error)
break;
}
if (p_error != no_parse_error) {
else
obj_dn = (__nis_object_dn_t *)
return (obj_dn);
}
/*
* FUNCTION: get_mapping_rule
*
* Parse mapping rule attributes
*
* RETURN VALUE: None. Errors determined by p_error
*
* INPUT: the attribute value and mapping rule type
*/
static void
const char *s,
int len,
{
const char *begin_token;
const char *end_token;
/* __nis_mapping_rule_t **r; */
token_type t;
int nRules = 0;
const char *s1;
int i;
/*
* The attribute value is of the form
* colattrspec *("," colattrspec)
* colattrspec = lhs "=" rhs
* lhs = lval | namespeclist
* rhs = rval | [namespec]
*/
for (;;) {
if ((next = (__nis_mapping_rule_t *)
break;
if (s == NULL)
break;
begin_token = s;
break;
if (s == NULL)
break;
}
break;
}
rule = (__nis_mapping_rule_t **)
malloc(sizeof (__nis_mapping_rule_t *));
break;
} else {
(nRules + 1) *
sizeof (__nis_mapping_rule_t *));
break;
}
begin_token = s;
if (s == NULL)
break;
if (t == comma_token)
continue;
if (t != no_token) {
break;
}
if (to_ldap) {
} else {
}
return;
}
if (rule) {
for (i = 0; i < nRules; i++)
free_mapping_rule(rule[i]);
}
if (next)
}
/*
* FUNCTION: get_lhs
*
* Parse left hand side of mapping rule attribute
*
* RETURN VALUE: NULL if error
* position of beginning rhs
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
get_lhs(const char *s,
const char *end_s,
{
token_type t;
const char *begin_token;
const char *end_token;
const char *sav_s;
__nis_mapping_element_t *e = NULL;
/*
* lhs can be expressed as:
* item
* (item)
* (item list)
* (fmt, item list)
*
* lhs = lval | namespeclist
* lval = "(" formatspec "," namespec *("," namespec) ")"
* namespeclist = namespec | "(" namespec *("," namespec) ")"
*/
for (; p_error == no_parse_error; ) {
begin_token = s;
if (s == NULL)
break;
if (t == no_token) {
break;
}
e = (__nis_mapping_element_t *)
if (e == NULL)
break;
if (t == open_paren_token) {
free(e);
e = NULL;
begin_token = s;
sav_s = s;
if (s == NULL)
break;
if (t == quoted_string_token) {
if (s == NULL)
break;
} else if (t == string_token) {
if (s == NULL)
break;
} else {
break;
}
} else if (t == string_token) {
if (s == NULL)
break;
if (!add_element(e, lhs))
break;
e = NULL;
} else {
break;
}
if (s == NULL)
break;
if (p_error == no_parse_error)
return (s);
}
if (e != NULL)
return (NULL);
}
/*
* FUNCTION: get_lhs_match
*
* Parse left hand side of mapping rule attribute in case of
* matching rule
*
* RETURN VALUE: NULL if error
* position of beginning rhs
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
{
token_type t;
const char *begin_token;
const char *end_token;
int n = 0;
int nElements = 0;
/*
* lval = "(" formatspec "," namespec *("," namespec) ")"
*/
for (; p_error == no_parse_error; ) {
begin_token = s;
if (s == NULL || t != quoted_string_token) {
break;
}
if (fmt_string == NULL)
break;
break;
continue;
}
if (s == NULL) {
break;
}
begin_token = s;
if (s == NULL)
break;
if (t != string_token) {
break;
}
itm = (__nis_mapping_item_t *)
sizeof (__nis_mapping_item_t));
break;
if (s == NULL)
break;
nElements++;
}
if (p_error != no_parse_error)
break;
if (s == NULL)
break;
fmt_string = NULL;
if (nElements == 0) {
break;
}
sizeof (__nis_mapping_element_t));
if (e == NULL)
break;
if (p_error == no_parse_error)
return (s);
}
for (n = 0; n < nElements; n++)
free_mapping_item(&item[n]);
}
if (fmt_string != NULL)
return (NULL);
}
/*
* FUNCTION: get_lhs_paren_item
*
* Parse left hand side of mapping rule attribute in case of
* (item1, ..., item-n)
*
* RETURN VALUE: NULL if error
* position of beginning rhs
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
{
token_type t;
const char *begin_token;
const char *end_token;
__nis_mapping_element_t *e = NULL;
int n = 0;
int i;
/*
* "(" namespec *("," namespec) ")"
*/
for (;;) {
sizeof (__nis_mapping_element_t));
if (e == NULL)
break;
if (s == NULL)
break;
n++;
begin_token = s;
if (s != NULL && t == close_paren_token) {
lhs->numElements = n;
if (n == 1)
return (s);
}
if (s == NULL || t != comma_token) {
break;
}
}
for (i = 0; i < n; i++)
free_mapping_element(&e[i]);
if (e != NULL)
free(e);
return (NULL);
}
/*
* FUNCTION: get_rhs
*
* Parse right hand side of mapping rule attribute
*
* RETURN VALUE: NULL if error
* position of beginning next mapping rule
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
{
/*
* This handles the following cases:
* name me_item
* (name) me_item
* (fmt, name-list) me_print
* (item, fmt) me_extract
*/
token_type t;
const char *begin_token;
const char *end_token;
__nis_mapping_element_t *e = NULL;
int n;
for (; p_error == no_parse_error; ) {
begin_token = s;
if (s == NULL)
break;
e = (__nis_mapping_element_t *)
if (e == NULL)
break;
if (t == string_token) {
} else if (t == open_paren_token) {
begin_token = s;
if (s == NULL)
break;
if (t == string_token) {
/* (item, fmt) - me_extract */
/* (item, "c") - me_split */
if (s == NULL)
break;
begin_token = s;
&t);
if (s == NULL)
break;
else if (t == close_paren_token) {
return (s);
} else if (t != comma_token) {
break;
}
begin_token = s;
&t);
if (s == NULL || t != quoted_string_token) {
p_error =
break;
}
(*begin_token == ESCAPE_CHAR &&
} else {
end_token - begin_token);
break;
break;
if (n != 1) {
p_error =
break;
}
e->type = me_extract;
}
} else if (t == quoted_string_token) {
/* (fmt, name-list) - me_print */
end_token - begin_token);
break;
s = get_print_mapping_element(s, end_s,
} else {
break;
}
} else {
break;
}
if (s == NULL)
break;
if (p_error == no_parse_error)
return (s);
}
if (str)
if (e != NULL)
return (NULL);
}
/*
* FUNCTION: get_print_mapping_element
*
* Parse a print mapping rule attribute in case of the form
* (fmt, name-list)
*
* RETURN VALUE: NULL if error
* position of beginning next mapping rule
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
char *fmt_string,
{
token_type t;
const char *begin_token;
const char *end_token;
char elide;
int n = 0;
int nSub = 0;
int numSubElements;
for (; p_error == no_parse_error; ) {
&numSubElements, TRUE))
break;
sizeof (__nis_mapping_sub_element_t));
if (subElement == NULL)
break;
continue;
}
if (nSub < numSubElements) {
if (s == NULL) {
break;
}
}
/* namelist may have parens around it */
if (s == NULL)
break;
nSub++;
}
if (p_error != no_parse_error)
break;
begin_token = s;
break;
} else if (t == close_paren_token) {
elide = '\0';
} else if (t == comma_token) {
begin_token = s;
if (s != NULL && t == quoted_string_token &&
(*begin_token == ESCAPE_CHAR &&
if (numSubElements != 1 ||
break;
}
break;
}
elide = *begin_token;
} else {
break;
}
if (s == NULL)
break;
}
if (p_error == no_parse_error)
return (s);
}
if (base)
if (subElement != NULL) {
for (n = 0; n < numSubElements; n++)
}
return (NULL);
}
/*
* FUNCTION: get_mapping_item
*
* Parse attribute string to get mapping item
*
* RETURN VALUE: NULL if error
* position of beginning next token after item
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
{
token_type t;
const char *begin_token;
const char *end_token;
char *index_string;
const char *s_sav;
int len;
/*
* A namepec is defined as follows:
* namespec = ["ldap:"] attrspec [searchTriple] |
* ["nis+:"] colspec [objectspec]
*
* The form of the item is assumed to be as follows:
* ["ldap:"] attrspec [searchTriple]
* attrspec = attribute | "(" attribute ")"
* searchTriple = ":" [baseDN] ["?" [scope] ["?" [filter]]]
* baseDN = Base DN for search
* scope = "base" | "one" | "sub"
* filter = LDAP search filter
*
* The form of the objectspec is as follows:
* ["nis+:"] colspec [objectspec]
* objectspec = objectname | "[" indexlist "]" tablename
* objectname = The name of a NIS+ object
* tablename = The name of a NIS+ table
* indexlist = colspec ["," colspec]
* colspec = colname "=" colvalue
* colname = The name of a column in the table
* colvalue = colvaluestring | \" colvaluestring \"
*/
for (; p_error == no_parse_error; ) {
while (s < end_s && is_whitespace(*s))
s++;
if (yp2ldap) {
} else {
begin_token = s;
}
} else {
} else {
begin_token = s;
}
}
if (s == NULL || t != string_token) {
break;
}
end_token - begin_token);
break;
begin_token = s;
s_sav = s;
if (s != NULL && t == colon_token) {
s = get_search_triple(s, end_s,
if (s == NULL)
break;
} else
s = s_sav;
while (s < end_s && is_whitespace(*s))
s++;
if (s < end_s && *s == OPEN_BRACKET) {
if (index_string == NULL)
break;
(void) parse_index(index_string,
if (p_error != no_parse_error)
break;
}
s_sav = s;
begin_token = s;
if (s != NULL && t == string_token) {
end_token - begin_token);
break;
} else
s = s_sav;
}
if (p_error == no_parse_error)
return (s);
}
return (NULL);
}
static const char *
get_print_sub_element(const char *s,
const char *end_s,
{
int k;
int n;
const char *begin_token;
const char *end_token;
token_type t;
k = 0;
continue;
}
if (s == NULL) {
break;
}
begin_token = s;
if (s == NULL)
break;
/*
* Determine if of the form
* ("fmt", (item), "delim") or
* ("fmt", item1, item2, ..., item n)
*/
if (t == open_paren_token) {
break;
}
if (s == NULL) {
break;
}
begin_token = s;
if (s == NULL)
break;
if (t != quoted_string_token ||
break;
}
break;
}
&print_item[k++], type);
if (s == NULL)
break;
if (p_error != no_parse_error)
break;
}
}
/*
* FUNCTION: get_subElement
*
* Parse attribute string to get sub element item
*
* RETURN VALUE: NULL if error
* position of beginning next token after item
*
* INPUT: the attribute value and mapping rule type
*/
static const char *
const char *s,
const char *end_s,
{
token_type t;
const char *begin_token;
const char *end_token;
char *fmt_string;
int n = 0;
int numItems = 0;
unsigned char delim;
/*
* What is the form of we are expecting here
* item me_item
* (item) me_item
* ("fmt", item1, item2, ..., item n) me_print
* ("fmt", (item), "elide") me_print
* (name, "delim") me_split
* (item, "fmt") me_extract
*/
for (; p_error == no_parse_error; ) {
begin_token = s;
if (s == NULL)
break;
if (t == string_token) { /* me_item */
if (s == NULL)
break;
return (s);
} else if (t != open_paren_token) {
break;
}
begin_token = s;
if (s == NULL)
break;
if (t != string_token && t != quoted_string_token) {
break;
}
if (t == string_token) {
/* me_item, me_extract or me_split */
if (s == NULL)
break;
begin_token = s;
if (s == NULL) {
break;
} else if (t == close_paren_token) {
if (yp2ldap) {
while (s < end_s && is_whitespace(*s))
s++;
if (s == end_s) {
p_error =
break;
}
s++;
while (s < end_s &&
is_whitespace(*s))
s++;
begin_token = s;
=
s_malloc(sizeof (__nis_mapping_item_t));
if (!subelement->
break;
s = get_mapping_item(s, end_s,
type);
if (s == NULL) {
p_error =
NULL;
break;
}
}
}
return (s);
} else if (t != comma_token) {
break;
}
begin_token = s;
if (s == NULL || t != quoted_string_token) {
break;
}
(*begin_token == ESCAPE_CHAR &&
/* me_split */
if (s == NULL)
break;
return (s);
}
e_type = me_extract;
}
if (fmt_string == NULL)
break;
break;
}
break;
sizeof (__nis_mapping_item_t));
if (print_item == NULL)
break;
}
if (s == NULL)
break;
}
if (s == NULL)
break;
if (e_type == me_extract) {
} else {
}
if (p_error == no_parse_error)
return (s);
}
if (print_item) {
for (n = 0; n < numItems; n++)
free_mapping_item(&print_item[n]);
}
return (NULL);
}
/*
* FUNCTION: skip_get_dn
*
* Get first token after dn
*
* RETURN VALUE: NULL if error (not valid dn)
* position of beginning next token after dn
*
* INPUT: the attribute value
*/
const char *
{
while (!done) {
if (last_comma) {
last_comma = FALSE;
}
break;
len = 1;
switch (*dn) {
case ESCAPE_CHAR:
len = 2;
break;
case DOUBLE_QUOTE_CHAR:
break;
case QUESTION_MARK:
case CLOSE_PAREN_CHAR:
case COLON_CHAR:
/* FALLTHRU */
case SEMI_COLON_CHAR:
case PLUS_SIGN:
case COMMA_CHAR:
if (!in_quote) {
return (last_dn);
} else {
}
break;
case EQUAL_CHAR:
if (!in_quote) {
return (NULL);
} else {
}
break;
default:
if (!is_whitespace(*dn))
break;
}
}
}
return (last_dn);
}
/*
* FUNCTION: get_ldap_filter_element
*
* Get an ldap filter element for a given string
*
* RETURN VALUE: NULL if error
* __nis_mapping_element_t if success
*
* INPUT: the string to parse
*/
static __nis_mapping_element_t *
const char *s,
const char *end_s
)
{
token_type t;
const char *begin_token;
const char *end_token;
char *format_str;
__nis_mapping_element_t *e = NULL;
begin_token = s;
if (s == NULL || t != open_paren_token)
return (NULL);
begin_token = s;
if (s == NULL || t != quoted_string_token)
return (NULL);
if (format_str == NULL)
return (NULL);
e = (__nis_mapping_element_t *)
if (e != NULL) {
(void) get_print_mapping_element(s, end_s,
format_str, e, mit_nisplus);
if (p_error != no_parse_error) {
e = NULL;
}
}
return (e);
}
/*
* FUNCTION: get_search_triple
*
* Get the search triple or if NULL determine if valid
*
* RETURN VALUE: NULL if error
* position of beginning next token after
* search triple
*
* INPUT: the attribute value
*/
const char *
const char *s,
const char *end_s,
)
{
const char *begin_token;
const char *end_token;
const char *s1;
/*
* The form of the searchTriple is assumed to be as follows:
* searchTriple = [baseDN] ["?" [scope] ["?" [filter]]]
* baseDN = Base DN for search
* scope = "base" | "one" | "sub"
* filter = LDAP search filter
*/
for (; p_error == no_parse_error; ) {
while (s < end_s && is_whitespace(*s))
s++;
if (s == end_s)
break;
if (!IS_TERMINAL_CHAR(*s)) {
begin_token = s;
if (s == NULL) {
break;
}
s - begin_token);
if (search_base == NULL)
break;
}
while (s < end_s && is_whitespace(*s))
s++;
if (s == end_s)
break;
}
if (!IS_TERMINAL_CHAR(*s)) {
break;
}
if (*s != QUESTION_MARK)
break;
s++;
while (s < end_s && is_whitespace(*s))
s++;
if (s == end_s)
break;
/* base, one, or sub, or empty value */
if (!IS_TERMINAL_CHAR(*s)) {
NULL) {
NULL) {
break;
}
s = s1;
while (s < end_s && is_whitespace(*s))
s++;
}
if (s == end_s)
break;
if (*s != QUESTION_MARK)
break;
s++;
while (s < end_s && is_whitespace(*s))
s++;
if (s == end_s || IS_TERMINAL_CHAR(*s))
break;
/* LDAP search filter */
if (*s == OPEN_PAREN_CHAR) {
begin_token = s;
if (s == NULL)
break;
s = end_token;
break;
} else {
begin_token = s;
if (s == NULL)
break;
s = end_token;
}
if (p_error == no_parse_error)
break;
}
search_base = NULL;
}
if (search_base != NULL)
}
}
/*
* FUNCTION: get_mapping_format
*
* Get the __nis_mapping_format_t from the string
*
* RETURN VALUE: FALSE if error
* TRUE if __nis_mapping_format_t returned
*
* INPUT: the format string
*/
static bool_t
const char *fmt_string,
int *nfmt,
int *numItems,
{
const char *f = fmt_string;
const char *ef;
int n = 0;
int nItems = 0;
f = fmt_string;
base = (__nis_mapping_format_t *)
return (FALSE);
n++;
for (;;) {
b = (__nis_mapping_format_t *)s_realloc(
if (b == NULL)
break;
base = b;
if (f == ef) {
if (nfmt)
*nfmt = n + 1;
if (numItems)
return (TRUE);
}
if (print_mapping)
else
if (f == NULL)
break;
nItems++;
n++;
}
return (FALSE);
}
/*
* FUNCTION: getIndex
*
* Returns a string containing the index
*
* RETURN VALUE: NULL if error
* a string containing the index
*
* INPUT: attribute containing the index
*/
static char *
{
const char *s = *s_cur + 1;
const char *s1;
char *s_index;
char *s_index1;
char *s_index_end;
while (s < s_end && is_whitespace(*s))
s++;
if (*s1 == ESCAPE_CHAR)
s1++;
else if (*s1 == DOUBLE_QUOTE_CHAR) {
} else if (in_quotes)
;
else if (*s1 == CLOSE_BRACKET) {
if (--n_brackets == 0)
break;
} else if (*s1 == OPEN_BRACKET)
n_brackets++;
}
if (n_brackets == 0) {
s_index++) {
if (*s_index == ESCAPE_CHAR) {
} else if (*s_index == DOUBLE_QUOTE_CHAR) {
} else if (!in_quotes &&
is_whitespace(*s_index)) {
continue;
}
}
s = s1 + 1;
while (s < s_end && is_whitespace(*s))
s++;
*s_cur = s;
}
} else
return (index);
}
/*
* FUNCTION: parse_index
*
* Parse attribute string to get __nis_index_t
*
* RETURN VALUE: FALSE if error
* TRUE if __nis_index_t returned
*
* INPUT: the attribute value to parse
*/
{
const char *begin_token;
const char *end_token;
char **name;
__nis_mapping_format_t *v = NULL;
token_type t;
int n = 0;
while (s < end_s) {
if (n > 0) {
if (s == NULL) {
break;
}
}
begin_token = s;
if (s == NULL)
break;
if (t != string_token) {
break;
}
if (s == NULL) {
break;
}
end_token - begin_token);
break;
}
begin_token = s;
if (s == NULL)
break;
if (t != string_token && t != quoted_string_token) {
break;
}
if (fmt_string == NULL)
break;
break;
fmt_string = NULL;
(n + 1) * sizeof (char *));
break;
(n + 1) * sizeof (__nis_mapping_format_t *));
break;
value[n] = v;
v = NULL;
index->numIndexes = ++n;
} else if (v != NULL) {
v = NULL;
}
}
if (p_error != no_parse_error) {
if (v != NULL)
if (fmt_string != NULL)
}
return (p_error != no_parse_error);
}
/*
* FUNCTION: get_deleteDisp
*
* Parse deleteDisp. Sets p_error if an error occurred.
*
* RETURN VALUE: TRUE on success
* FAILURE on failure
*
* INPUT: begin and end of string and __nis_object_dn_t
*/
static bool_t
{
/*
* deleteDisp: "always" | perDbId | "never"
* perDbId: "dbid" "=" delDatabaseId
*/
!= NULL) {
s_begin++;
} else {
s_begin++;
s_begin++;
s_end--;
} else {
}
}
} else {
}
return (p_error == no_parse_error);
}