/*
* 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 <sys/systeminfo.h>
#include <strings.h>
#include "nis_parse_ldap_conf.h"
#include "ldap_attr.h"
#include "ldap_util.h"
#include "ldap_structs.h"
/*
* If 'name' doesn't end in a trailing dot, return a copy with the
* value of "nisplusLDAPbaseDomain" appended. Otherwise, return a
* copy of 'name'. If deallocate!=0, free 'name'.
*/
char *
int l;
char *full;
if (name == 0)
} else {
}
if (deallocate)
return (full);
}
/*
* Convert a domain name ("x.y.z.", say) to a "dc=..." type LDAP equivalent
* ("dc=x,dc=y,dx=z"). The domain name supplied MUST be terminated by a
* trailing dot. If 'domain' is NULL, the value of "nisplusLDAPbaseDomain"
* is converted.
*/
char *
char *base = 0;
int l, i;
if (domain == 0)
if (domain == 0)
return (0);
for (l = 0, i = 0; domain[i] != '\0'; i++) {
if (domain[i] == '.') {
domain[i] = '\0';
if (l != 0)
else
l = i+1;
}
}
return (base);
}
/*
* If 'name' ends in a trailing comma, append the value of the
* "defaultSearchBase". If deallocate!=0, free 'name'.
*/
char *
int err = 0;
deallocate));
}
/*
* If the 'item' string ends in a comma, append 'base', and return
* the result. On exit, '*err' will be zero if successful, non-zero
* otherwise. If 'dealloc' is non-zero, 'item' is freed; this happens
* even if an error status is returned.
*
* The return value is always allocated, and must be freed by the caller.
*/
char *
char *new;
/*
* Make sure that 'err' points to something valid, so that we can
* dispense with all those 'if (err != 0)'.
*/
if (err == 0)
/* Establish default (successful) error status */
*err = 0;
/* Trivial case 1: If 'item' is NULL, return a copy of 'base' */
if (item == 0) {
if (new == 0)
*err = -1;
return (new);
}
/* Trivial case 2: If 'base' is NULL, return a copy of 'item' */
if (base == 0) {
if (new == 0)
*err = -1;
if (dealloc)
return (new);
}
/* If 'item' is the empty string, return a copy of 'base' */
if (len <= 0) {
if (new == 0)
*err = -1;
if (dealloc)
return (new);
}
/*
* If 'item' ends in a comma, append 'base', and return a copy
* of the result. Otherwise, return a copy of 'item'.
*/
if (new != 0) {
} else {
*err = -1;
}
} else {
if (new == 0)
*err = -1;
}
if (dealloc)
return (new);
}
/*
* Despite its general-sounding name, this function only knows how to
* turn a list of attributes ("a,b,c") into an AND filter ("(&(a)(b)(c))").
*/
char *
int len, s, e, c;
return (0);
/* Assume already of appropriate form if first char is '(' */
if (str == 0)
return (0);
if (filter == 0) {
return (0);
}
for (s = c = 0; s < len; s = e+1) {
/* Skip blank space, if any */
/* Find delimiter (comma) or end of string */
str[e] = '\0';
if (tmp == 0) {
return (0);
}
c++;
}
/*
* If there's just one component, we return it as is. This
* means we avoid turning "objectClass=posixAccount" into
* "(&(objectClass=posixAccount))".
*/
if (c == 1) {
return (str);
}
/* Add the closing ')' */
return (filter);
}
/*
* Split an AND-filter string into components.
*/
char **
int nc = 0, s, e, i;
int len;
return (0);
/* Is it just a plain "attr=val" string ? If so, return a copy */
if (comp == 0)
return (0);
if (comp[0] == 0) {
return (0);
}
if (numComps != 0)
*numComps = 1;
return (comp);
}
if (str == 0)
return (0);
/* Skip past the '(' */
s++;
if (s >= len)
break;
str[e] = '\0';
if (new == 0) {
if (comp != 0) {
for (i = 0; i < nc; i++)
comp = 0;
}
nc = 0;
break;
}
for (i = 0; i < nc; i++)
comp = 0;
nc = 0;
break;
}
nc++;
}
}
if (numComps != 0)
return (comp);
}
void
int i;
if (comp == 0)
return;
for (i = 0; i < numComps; i++) {
}
}
char **
return (comp);
if (str == 0)
return (0);
if (tmp == 0) {
return (0);
}
*numComps += 1;
return (comp);
}
char *
int i;
__nis_buffer_t b = {0, 0};
return (0);
for (i = 0; i < numComps; i++) {
if (comp[i] == 0)
continue;
}
return (b.buf);
}
void
int i;
if (dn == 0)
return;
for (i = 0; i < numDN; i++) {
}
}
/*
* Search the supplied rule-value structure array for any attributes called
* "dn", and return their values. If the "dn" value(s) end in a comma, they
* get the 'defBase' value appended.
*/
char **
int *numDN) {
char **dn;
return (0);
if (msg == 0)
/* Avoid realloc() by pre-allocating 'dn' at maximum size */
if (dn == 0)
return (0);
/* Looking for string-valued attribute called "dn" */
int err = 0;
if (err != 0) {
return (0);
}
ndn++;
break;
}
}
}
return (dn);
}