/*
* 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
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Directory lookup functions. These are shims that translate from the API
* into the RPC protocol.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <malloc.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include "directory.h"
#include "directory_private.h"
#include <rpcsvc/idmap_prot.h>
#include "directory_library_impl.h"
#include "sized_array.h"
static void directory_datum_free(directory_datum_t d);
/*
* This is the actual implementation of the opaque directory_t structure.
*/
struct directory {
};
/*
* Set up a directory search context.
*/
{
directory_t d;
d = calloc(1, sizeof (*d));
if (d == NULL)
goto nomem;
"Error: %1",
NULL);
goto err;
}
*ret = d;
return (NULL);
"Insufficient memory setting up directory access", NULL);
err:
directory_close(d);
return (de);
}
/*
* Tear down a directory search context.
*
* Does nothing if d==NULL.
*/
void
{
if (d == NULL)
return;
clnt_destroy(d->client);
free(d);
}
/*
* Given a list of identifiers, a list of their types, and a list of attributes,
* return the information.
*/
directory_t d,
char **ids,
int nids,
char *types,
char **attr_list)
{
int nattrs;
int i;
if (nids == 0) {
/* LOOP */;
}
/* LOOP */;
if (cs != RPC_SUCCESS) {
"Get_common RPC (%1)%2", errbuf,
goto err;
}
goto err;
}
for (i = 0; i < nids; i++) {
goto err;
}
return (NULL);
err:
return (de);
}
/*
* Free the results from a directory_get_*() request.
*/
void
{
int i;
int j;
int k;
return;
/* For each directory entry returned */
for (i = 0; i < sized_array_n(del); i++) {
/* For each attribute */
for (k = 0; k < sized_array_n(dav); k++)
directory_datum_free(dav[k]);
}
}
}
}
}
/*
* Create a directory datum. Note that we allocate an extra byte and
* zero it, so that strings get null-terminated. Return NULL on error.
*/
static
{
void *p;
if (p == NULL)
return (NULL);
*((char *)p + len) = '\0';
return (p);
}
/*
* Return the size of a directory_datum_t. Note that this does not include
* the terminating \0, so it represents the value as returned by LDAP.
*/
{
/*
* Deduct the terminal \0, so that binary data gets the
* expected length.
*/
return (sized_array_n(d) - 1);
}
static
void
{
sized_array_free(d);
}
/*
* Unmarshall an RPC directory entry into an API directory entry.
*/
static
{
int nattrs;
int i;
/* If the entry wasn't found, leave the entry attrs and err NULL. */
return (NULL);
return (NULL);
}
return (directory_error("ENOMEM.copy_directory_entry",
"Insufficient memory copying directory entry", NULL));
}
for (i = 0; i < nattrs; i++) {
return (de);
}
return (NULL);
}
/*
* Unmarshall an RPC directory attribute value into the API equivalent.
*
* Note that on error some entries may have been copied, and so
* the caller needs to clean up dav. This is normally not a problem
* since the caller will have called this function several times and
* will need to clean up the results from the other calls too.
*/
static
{
int i;
int nvals;
/* If it wasn't found, leave the corresponding entry NULL */
return (NULL);
return (directory_error("ENOMEM.copy_directory_attribute_value",
"Insufficient memory copying directory entry", NULL));
}
for (i = 0; i < nvals; i++) {
return (directory_error(
"ENOMEM.copy_directory_attribute_value",
"Insufficient memory copying directory entry",
NULL));
}
}
return (NULL);
}
/*
* Free the results of a directory RPC request.
*/
static
void
{
}