/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include <locale.h>
#include <syslog.h>
#include "ns_internal.h"
/*
* Calculate a hash for a string
* Based on elf_hash algorithm, hash is case insensitive
* Uses tolower instead of _tolower because of I18N
*/
static unsigned long
{
unsigned int hval = 0;
while (*str) {
unsigned int g;
if ((g = (hval & 0xf0000000)) != 0)
hval ^= g >> 24;
hval &= ~g;
}
return ((unsigned long)hval);
}
/*
* Scan a hash table hit for a matching hash entry.
* Assume service and str are non-NULL.
*/
static ns_hash_t *
{
while (idx) {
return (idx);
}
}
}
/*
* Find an entry in the hash table
*/
static ns_hash_t *
{
unsigned long hash;
return (NULL);
return (hashp);
}
/*
* free a map entry
*/
static void
{
char **ptr;
return;
}
}
}
}
/*
* Remove a hash table entry.
* This function is not MT safe.
*/
static ns_hash_t *
{
free(p);
return (next);
}
/*
* destroy the hash table.
* This function is not MT safe.
*/
void
{
int i;
return;
for (i = 0; i < NS_HASH_MAX; i++) {
}
}
}
/*
* Add a hash entry to the hash table.
* This function is not MT safe.
* Assume map, map->orig, map->service are non-NULL.
*/
int
{
unsigned long hash;
return (NS_HASH_RC_CONFIG_ERROR);
return (NS_HASH_RC_EXISTED);
}
return (NS_HASH_RC_NO_MEMORY);
return (NS_HASH_RC_SUCCESS);
}
/*
* Parse an attribute map string.
* Assume space is the only legal whitespace.
* attributeMap syntax:
* attributeMap = serviceId ":" origAttribute "="
* attributes
* origAttribute = attribute
* attributes = wattribute *( space wattribute )
* wattribute = whsp newAttribute whsp
* newAttribute = descr | "*NULL*"
* attribute = descr
*
* objectclassMap syntax:
* objectclassMap = serviceId ":" origObjectclass "="
* objectclass
* origObjectclass = objectclass
* objectclass = keystring
*/
int
{
int i, max;
return (NS_HASH_RC_SYNTAX_ERROR);
return (NS_HASH_RC_NO_MEMORY);
return (NS_HASH_RC_SYNTAX_ERROR);
}
return (NS_HASH_RC_NO_MEMORY);
}
max = 1;
max++;
dptr++;
}
}
return (NS_HASH_RC_NO_MEMORY);
}
while (*sptr) {
sptr++;
dptr++;
return (NS_HASH_RC_NO_MEMORY);
}
mapp++;
}
return (NS_HASH_RC_SUCCESS);
}
static void
{
return;
}
/*
* Parse a service descriptor
* and create a service descriptor struct
* SD Format:
* serviceid:[base][?[scope][?[filter]]];[[base][?[scope][?[filter]]]]
* desc format:
* [base][?[scope][?[filter]]]
*/
typedef enum _ns_parse_state {
static
int
{
int i, rc;
int quoted = 0;
int wasquoted = 0;
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_INVALID_PARAM);
ptr = (ns_ldap_search_desc_t *)
return (NS_LDAP_MEMORY);
/* Get the default scope */
(void) __ns_ldap_freeError(errorp);
return (NS_LDAP_MEMORY);
}
else
(void) __ns_ldap_freeParam(¶mVal);
empty = 0;
switch (state) {
case P_INIT:
/* No basedn */
break;
}
break;
}
/* No SSD */
break;
}
break;
}
/* prepare to copy DN */
break;
}
/* error */
break;
}
/* escaped CHARS */
sptr++;
} else {
}
quoted = 1;
wasquoted = 1;
} else {
}
break;
case P_INIFILTER:
/* No filter and no more SSD */
break;
}
/* prepare to copy DN */
break;
}
/* error */
break;
}
/* escaped CHARS */
sptr++;
} else {
}
quoted = 1;
wasquoted = 1;
} else {
}
break;
case P_SCOPE:
buf[0] = '\0';
/* no more SSD */
break;
}
sptr += 4;
sptr += 3;
sptr += 3;
}
/* no more SSD */
sptr--;
break;
}
break;
}
state = P_INIFILTER;
quoted = 0;
wasquoted = 0;
break;
case P_BASEDN:
case P_FILTER:
if (quoted) {
/* Quoted */
break;
}
/* escaped CHARS */
sptr++;
} else {
}
/* fall through to char copy */
/* end of string */
*dptr = '\0';
quoted = 0;
break;
}
/* else fall through to char copy */
} else {
/* Unquoted */
/* error past end of quoted string */
break;
}
break;
}
/* escaped chars */
sptr++;
}
/* fall through to char copy */
/* error */
break;
/* if filter error */
break;
}
/* end of basedn goto scope */
*dptr = '\0';
break;
/* end of current SSD */
*dptr = '\0';
break;
}
}
/* normal character to copy */
break;
case P_END:
break;
}
return (NS_LDAP_CONFIG);
default: /* error should never arrive here */
case P_ERROR:
return (NS_LDAP_CONFIG);
case P_MEMERR:
return (NS_LDAP_MEMORY);
}
}
if (quoted) {
return (NS_LDAP_INVALID_PARAM);
}
/* get default base */
if (rc != NS_LDAP_SUCCESS) {
if (dns) {
}
(void) __ns_ldap_freeError(&error);
return (NS_LDAP_MEMORY);
}
}
return (NS_LDAP_SUCCESS);
}
/*
* Build up the service descriptor array
*/
static int
{
*cnt = 0;
*max = NS_SDESC_MAX;
*sdlist = (ns_ldap_search_desc_t **)
return (-1);
*max += NS_SDESC_MAX;
tmplist = (ns_ldap_search_desc_t **)
*max * sizeof (ns_ldap_search_desc_t *));
return (-1);
else
}
(*cnt)++;
return (0);
}
/*
* Exported Search Descriptor Routines
*/
const char *service,
{
int rc;
int slen;
int vers;
return (NS_LDAP_INVALID_PARAM);
if (rc != NS_LDAP_SUCCESS) {
return (rc);
}
cnt = 0;
max = 0;
gettext("No configuration information available."));
NULL);
return (NS_LDAP_CONFIG);
}
/* If using version1 or no sd's process SEARCH_DN if available */
return (rc);
}
/* Convert a SEARCH_DN to a search descriptor */
ret = (ns_ldap_search_desc_t *)
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
return (NS_LDAP_MEMORY);
}
(void) __ns_ldap_freeASearchDesc(ret);
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
return (NS_LDAP_MEMORY);
}
/* default scope */
(void) __ns_ldap_freeASearchDesc(ret);
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
return (rc);
}
else
(void) __ns_ldap_freeParam(¶mVal);
if (rc < 0) {
(void) __ns_ldap_freeASearchDesc(ret);
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
return (NS_LDAP_MEMORY);
}
}
return (NS_LDAP_SUCCESS);
}
(void) __ns_ldap_freeParam(¶m);
return (NS_LDAP_SUCCESS);
}
/* Process the version2 sd's */
continue;
continue;
srv++;
/* Process 1 */
if (rc != NS_LDAP_SUCCESS) {
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
"Invalid serviceSearchDescriptor (%s). "
"Illegal configuration"), *sdl);
(void) __ns_ldap_freeParam(¶m);
return (rc);
}
}
if (rc < 0) {
(void) __ns_ldap_freeSearchDescriptors(&sdlist);
(void) __ns_ldap_freeParam(¶m);
return (NS_LDAP_MEMORY);
}
}
}
(void) __ns_ldap_freeParam(¶m);
return (NS_LDAP_SUCCESS);
}
int
{
return (NS_LDAP_SUCCESS);
}
return (NS_LDAP_SUCCESS);
}
/*
* Exported Attribute/Objectclass mapping functions.
*/
/*
* This function is not supported.
*/
/* ARGSUSED */
const char *service,
{
return (NS_LDAP_OP_FAILED);
}
int
{
return (NS_LDAP_SUCCESS);
}
if (ptr->mappedAttr) {
}
}
return (NS_LDAP_SUCCESS);
}
char **__ns_ldap_getMappedAttributes(
const char *service,
const char *origAttribute)
{
char **ret;
return (NULL);
else
return (ret);
}
char **__ns_ldap_getOrigAttribute(
const char *service,
const char *mappedAttribute)
{
char **ret;
return (NULL);
else
return (ret);
}
/*
* This function is not supported.
*/
/* ARGSUSED */
const char *service,
{
return (NS_LDAP_OP_FAILED);
}
int
{
return (NS_LDAP_SUCCESS);
}
}
}
return (NS_LDAP_SUCCESS);
}
char **__ns_ldap_getMappedObjectClass(
const char *service,
const char *origObjectClass)
{
char **ret;
return (NULL);
else
return (ret);
}
char **__ns_ldap_getOrigObjectClass(
const char *service,
const char *mappedObjectClass)
{
char **ret;
return (NULL);
else
return (ret);
}
char **__ns_ldap_mapAttributeList(
const char *service,
const char * const *origAttrList)
{
const char * const *opp;
int i;
if (origAttrList == NULL)
return (NULL);
opp = origAttrList;
;
return (NULL);
opp = origAttrList;
return (NULL);
}
} else {
return (NULL);
}
}
}
return (cpp);
}
char *
const char *service,
const char *origAttr)
{
char **npp;
char *mappedAttr;
return (NULL);
} else {
}
return (mappedAttr);
}