nisplus_common.c revision cb5caa98562cf06753163f558cbcfe30b8f4673a
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Common code used by name-service-switch "nisplus" backends
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "nisplus_common.h"
#include "nisplus_tables.h"
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#define ORGDIR1 ".org_dir"
#define ORGDIR2 ".org_dir."
#define ORGDIRLEN 7
extern uint_t __nis_force_hard_lookups;
extern int inet_pton(int, const char *, void *);
static nss_status_t
{
if (nis_res == 0) {
return (NSS_UNAVAIL);
}
switch (NIS_RES_STATUS(nis_res)) {
case NIS_SUCCESS:
case NIS_S_SUCCESS:
case NIS_CBRESULTS:
errno = 0;
return (NSS_SUCCESS);
case NIS_NOTFOUND:
case NIS_PARTIAL:
case NIS_NOSUCHNAME:
errno = 0;
return (NSS_NOTFOUND);
case NIS_NAMEUNREACHABLE:
case NIS_S_NOTFOUND:
case NIS_TRYAGAIN:
return (NSS_TRYAGAIN);
default:
return (NSS_UNAVAIL);
}
}
const char *name;
int extra_flags;
nis_result **res_p;
{
__nis_force_hard_lookups, 0, 0);
return (switch_err(*res_p));
}
static nss_status_t
{
int parsestat;
return (res);
}
if (NIS_RES_OBJECT(result) == 0) {
return (NSS_NOTFOUND);
}
if (parsestat != NSS_STR_PARSE_SUCCESS)
goto fail;
/*
* If called by nscd's switch engine, the data
* is available in args->buf.buffer and there is
* no need to marshall it.
*
* Note for some dbs like ethers, the obj2str()
* routine will always put the NFF data in
* be->buffer because we cannot determine if
* we are inside nscd or inside the application.
*/
return (NSS_SUCCESS);
}
/*
* If the data is in be->buffer it needs
* to be marshalled.
*/
goto fail;
}
if (parsestat == NSS_STR_PARSE_SUCCESS) {
}
}
return (NSS_SUCCESS);
}
fail:
}
if (parsestat == NSS_STR_PARSE_ERANGE) {
/* We won't find this otherwise, anyway */
return (NSS_NOTFOUND);
} else if (parsestat == NSS_STR_PARSE_PARSE) {
return (NSS_NOTFOUND);
}
return (NSS_UNAVAIL);
}
const char *column_name;
const char *keyname;
{
nis_result *r;
/* make sure we don't overflow stack: 1223320 */
4 /* size of '[' + '=' + ']' + '\0' */
> sizeof (namebuf)) { /* BUFSIZ for array */
return (NSS_NOTFOUND);
}
/*
* Assumes that "keyname" is a null-terminated string.
*/
be->table_name);
__nis_force_hard_lookups, 0, 0);
if (r != 0)
nis_freeresult(r);
return (res);
}
/*
* _nss_nisplus_expand_lookup() -- Takes an unqualified or partially
* qualified name as a key and uses EXPAND_NAME to do a DNS-style lookup.
* Map <name>.<domain> => [<column_name>=<name>]<table>.org_dir.<domain>
* and in the (common) degenerate case
* <name> => [<column_name>=<name>]<table>.org_dir
*
* Can also take a hostaddr as a key. In that case, use the degenerate
* mapping described above.
*/
const char *column_name;
const char *keyname;
const char *table; /* one component table name (no dots) */
{
nis_result *r;
const char *directory;
char *p;
/* make sure we don't overflow stack: 1223320 */
4 /* size of '[' + '=' + ']' + '\0' */
> sizeof (namebuf)) { /* BUFSIZ for array */
return (NSS_NOTFOUND);
}
/*
* Assumes that "keyname" is a null-terminated string.
*/
if (((directory = nis_local_directory()) == 0) ||
return (0);
}
if (p == 0) {
} else {
}
} else {
p = 0;
}
if (p != 0) {
}
__nis_force_hard_lookups, 0, 0);
if (r != 0)
nis_freeresult(r);
return (res);
}
int n_ops;
const char *tblname; /* (Unqualified) name of NIS+ table */
{
const char *directory = nis_local_directory();
#ifdef DEBUG
#endif /* DEBUG */
if (directory == 0 ||
return (0);
}
return (0);
}
return ((nss_backend_t *)be);
}
/*ARGSUSED*/
void *dummy;
{
if (be != 0) {
/* === Should change to invoke ops[ENDENT] ? */
(void) _nss_nisplus_endent(be, 0);
if (be->table_name != 0) {
}
}
}
return (NSS_SUCCESS); /* In case anyone is dumb enough to check */
}
static void
{
/*
* Grunge to treat netobj with n_len == 0 as a distinct netobj
*/
/*
* Could trust malloc(0) to do the right thing;
* would rather not.
*/
}
} else {
}
}
}
}
void *a;
{
nis_result *r;
return (NSS_NOTFOUND);
} else {
}
be->path_index++;
nis_freeresult(r);
r = 0;
goto next_table;
}
if (switch_err(r) == NSS_SUCCESS) {
}
if (r != 0)
nis_freeresult(r);
return (res);
}
/*ARGSUSED*/
void *dummy;
{
size_t n;
char *table_name;
char *table_path;
char *p;
if (res)
return (ns_status);
}
return (NSS_UNAVAIL);
}
/*
* If the name is actually a link to a table, then
* the table name will be different (since we followed
* links). We get the name of the real table here.
*/
table_name = (char *)malloc(n);
if (table_name == 0) {
return (NSS_UNAVAIL);
}
/* save table path */
/* find approximate number of path entries */
n = 2; /* +1 for table itself, +1 for path with no colons */
p = table_path;
while ((p = strchr(p, ':')) != 0) {
n++;
p++; /* skip ':' */
}
/* allocate path list to hold 'n' entries */
return (NSS_UNAVAIL);
}
/* steal table_path from res so it is not freed */
}
be->path_index = 0;
/*
* Don't bother freeing no.n_bytes, because we'll
* probably need it
*/
return (NSS_SUCCESS);
}
/*ARGSUSED*/
void *dummy;
{
}
if (be->table_path)
}
}
be->table_path = 0;
be->path_index = 0;
return (NSS_SUCCESS);
}
int
/*
* process remaining entries
*/
/* object should be non-null */
return (NSS_STR_PARSE_PARSE);
return (NSS_STR_PARSE_PARSE);
}
/* skip if protocols doesn't match for services */
if (protolen != protokeylen ||
continue;
}
/*
* add the "name" to the list if it doesn't
* match the "cname"
*/
if (p >= limit)
return (NSS_STR_PARSE_ERANGE);
" %s", name);
linep = p;
}
}
return (NSS_STR_PARSE_SUCCESS);
}