/*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <synch.h>
#include <lber.h>
#include <ldap.h>
#include "fedfs_impl.h"
typedef struct nce_cache_node {
char *host;
int port;
int numnce;
static nce_entry_t **
{
int i;
return (NULL);
for (i = 0; i < numnce; i++) {
goto err;
goto err;
goto err;
}
return (newnces);
err:
return (NULL);
}
/*
* Store NCEs in the cache
*/
static void
{
if (numnce == 0)
return;
#ifdef DEBUG
#endif
/* Create a new cache entry */
return;
goto err;
goto err;
(void) mutex_lock(&nce_cache_lock);
/* Look for an existing entry */
break;
prev = n;
}
if (n == NULL) {
/* Not found, add entry to tail */
else
} else {
/* Found, replace the old entry */
else
#ifdef DEBUG
#endif
free(n);
}
(void) mutex_unlock(&nce_cache_lock);
return;
err:
}
/*
* Look up NCEs in the cache
*/
static int
{
(void) mutex_lock(&nce_cache_lock);
/* Look for an existing entry */
if (t - n->timestamp >= NCE_CACHE_TIMEOUT) {
else
#ifdef DEBUG
#endif
free(n);
n = &temp;
continue;
}
prev = n;
break;
}
if (n == NULL) {
(void) mutex_unlock(&nce_cache_lock);
return (0);
}
#ifdef DEBUG
#endif
(void) mutex_unlock(&nce_cache_lock);
return (0);
return (n->numnce);
}
/*
* Return a list of NCEs (NSDB container entries) for an LDAP
* must be freed by the caller with free_nces() or equivalent.
* Each NCE is returned as the naming context and the prefix
* of the NCE object within the NC.
*
* An NCE is an attribute which may be present at the root of a
* naming context to indicate where FedFS entries are to be found.
* At least one NCE must be present for an LDAP server to be an
* NSDB for FedFS.
*
* Return values: the number of NCEs in the array (may be zero),
* or -1 in the case of communications errors.
*/
int
{
char *a;
#ifdef DEBUG
char *dn;
#endif
char **nclist;
/* Sanity */
return (-1);
/*
* Look in the cache first
*/
if (numnce > 0)
return (numnce);
/*
* Connect and bind to the directory anonymously.
*/
#ifdef DEBUG
perror("nsdb_connect");
#endif
return (-1);
}
/*
* Perform search for naming contexts, equivalent to:
* ldapsearch -h $host -b "" -s base objectClass=* namingContexts
*/
attribs[0] = "namingContexts";
filter[0] = '\0';
#ifdef DEBUG
#endif
(void) ldap_unbind(ld);
return (-1);
}
numnc = 0;
/* for each entry print out name + all attributes and values */
e = ldap_next_entry(ld, e)) {
#ifdef DEBUG
#endif
break;
#ifdef DEBUG
#endif
sizeof (char *) * (numnc + 1));
numnc++;
}
ldap_memfree(a);
}
}
(void) ldap_msgfree(result);
numnce = 0;
/*
* Perform search for NCE in each naming context, equivalent to:
* ldapsearch -h $host -b $nc objectClass=fedfsNsdbContainerInfo \
* fedfsNcePrefix
*/
for (i = 0; i < numnc; i++) {
#ifdef DEBUG
i, nclist[i]);
#endif
attribs[0] = "fedfsNcePrefix";
filter[0] = '\0';
#ifdef DEBUG
#endif
continue;
}
/* for each entry print out name + all attributes and values */
e = ldap_next_entry(ld, e)) {
#ifdef DEBUG
dn);
#endif
break;
#ifdef DEBUG
"attr %s, val[%d] %s, len %d\n",
#endif
/*
* NCE is prefix plus the namingContext
*/
sizeof (nce_entry_t *) *
(numnce + 1));
sizeof (nce_entry_t), 1);
numnce++;
}
ldap_memfree(a);
}
}
(void) ldap_msgfree(result);
}
for (i = 0; i < numnc; i++)
(void) ldap_unbind(ld);
#ifdef DEBUG
for (i = 0; i < numnce; i++)
#endif
return (numnce);
}
/*
* Free list of NCEs as returned from list_nces().
*/
void
{
int i;
return;
for (i = 0; i < n; i++) {
}
}
char *
{
int size;
char *dn;
return (NULL);
return (NULL);
else
return (dn);
}
#ifdef MAIN
int
{
char **nce;
int i, n;
for (i = 0; i < n; i++)
return (0);
}
#endif