ns_nisplus.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <string.h>
#include <ctype.h>
#include <nsswitch.h>
#include <rpcsvc/nfs_prot.h>
#include "automount.h"
#define KEY 0
#define CONTENTS 1
/*
* The following macro is for making the values returned
* from name services switch compatible. Earlier when a
* name service returned 0 it meant it could not find
* the requested stuff and a ret val of > 0 implied
* success. This is opposite of what switch expects
*/
int (*)(nis_name, nis_object *, void *), void *);
static int mastermap_callback(char *, nis_object *, void *);
static int directmap_callback(char *, nis_object *, void *);
static int nisplus_err(int);
static int nisplus_match(char *, char *, char *, char **, int *);
static int readdir_callback(char *, nis_object *, void *);
static char *nisplus_subdomain = NULL;
struct loadmaster_cbdata {
char *ptr1;
char **ptr2;
char ***ptr3;
};
struct loaddirect_cbdata {
char *ptr1;
char *ptr2;
char **ptr3;
char ***ptr4;
};
struct dir_cbdata {
int error;
};
void
{
#ifdef lint
#endif /* lint */
nisplus_subdomain = "org_dir";
}
/*ARGSUSED*/
int
char *key;
char *map;
char **stack;
char ***stkptr;
{
char *lp;
int nserr;
if (iswildcard)
*iswildcard = FALSE;
if (nserr) {
if (nserr == __NSW_NOTFOUND) {
/* Try the default entry "*" */
&nis_len)))
goto done;
else {
if (iswildcard)
*iswildcard = TRUE;
}
} else
goto done;
}
/*
* at this point we are sure that nisplus_match
* succeeded so massage the entry by
* 1. ignoring # and beyond
* 2. trim the trailing whitespace
*/
*lp = '\0';
if (len == 0) {
goto done;
}
*lp-- = '\0';
goto done;
}
done:
if (nis_line)
return (nserr);
}
char *mapname;
char *defopts;
char **stack;
char ***stkptr;
{
char indexedname[NIS_MAXNAMELEN];
int err;
struct loadmaster_cbdata master_cbdata;
if (nisplus_subdomain == NULL)
return (__NSW_UNAVAIL);
}
mastermap_callback, (void *) &master_cbdata);
return (__NSW_UNAVAIL);
if (verbose)
"nis_list failed"));
return (nisplus_err(err));
}
return (__NSW_SUCCESS);
}
char **stack;
char ***stkptr;
{
char indexedname[NIS_MAXNAMELEN];
struct loaddirect_cbdata direct_cbdata;
int err;
if (nisplus_subdomain == NULL)
return (__NSW_UNAVAIL);
}
directmap_callback, (void *)&direct_cbdata);
return (__NSW_UNAVAIL);
if (verbose)
"nis_list failed"));
return (nisplus_err(err));
}
return (__NSW_SUCCESS);
}
static int
int err;
{
switch (err) {
case NIS_SUCCESS:
case NIS_S_SUCCESS:
return (__NSW_SUCCESS);
case NIS_NOTFOUND:
case NIS_S_NOTFOUND:
return (__NSW_NOTFOUND);
case NIS_TRYAGAIN:
return (__NSW_TRYAGAIN);
default:
return (__NSW_UNAVAIL);
}
}
/*
* The first param is not used, but it is reqd
* because this function is called by nisplus
* library functions
*/
/* ARGSUSED */
static int
char *tab;
void *udata;
{
int key_len, contents_len;
int i;
return (0);
return (0);
contents++;
return (0);
return (0);
for (i = 0; i < 256; i++)
qbuff[i] = ' ';
"%s in nisplus master map: entry too long (max %d chars)",
return (0);
}
for (i = 0; i < 256; i++)
qbuff[i] = ' ';
"%s in nisplus master map: entry too long (max %d chars)",
return (0);
}
pmap++; /* skip blanks in front of map */
opts++;
if (*opts) {
*opts++ = '\0';
opts++;
if (*opts == '-')
opts++;
else
}
/*
* Check for no embedded blanks.
*/
} else
pr_msg("Warning: invalid entry for %s in nisplus map %s ignored.\n",
return (0);
}
/*
* The first param is not used, but it is reqd
* because this function is called by nisplus
* library functions
*/
/* ARGSUSED */
static int
char *tab;
void *udata;
{
char *key;
char dir[256];
int key_len;
return (0);
return (0);
return (0);
}
static int
char **nis_line;
int *nis_len;
{
int err;
char indexedname[NIS_MAXNAMELEN];
if (nisplus_subdomain == NULL)
return (__NSW_UNAVAIL);
if (*map != '[')
else
}
if (trace > 1)
if (trace > 1) {
else
}
return (__NSW_UNAVAIL);
return (nisplus_err(err));
}
return (__NSW_NOTFOUND);
}
if (verbose)
"nisplus map %s, entry for %s has NULL value field",
return (__NSW_UNAVAIL);
}
/*
* so check for the length; it should be less than LINESZ
*/
" is too long %d chars (max %d)",
return (__NSW_UNAVAIL);
}
return (__NSW_UNAVAIL);
}
return (__NSW_SUCCESS);
}
char *nsmap;
int *error;
int *cache_time;
char **stack;
char ***stkptr;
{
char indexedname[NIS_MAXNAMELEN];
struct dir_cbdata readdir_cbdata;
int err;
#ifdef lint
#endif /* lint */
if (trace > 1)
*error = 0;
if (nisplus_subdomain == NULL)
return (__NSW_UNAVAIL);
}
readdir_callback, (void *)&readdir_cbdata);
return (__NSW_UNAVAIL);
if (readdir_cbdata.error)
printf("nisplus can't list map, %s: %s",
"nis_list failed"));
if (*error == 0)
return (nisplus_err(err));
}
return (__NSW_SUCCESS);
}
/*
* The first param is not used, but it is reqd
* because this function is called by nisplus
* library functions
*/
/* ARGSUSED */
static int
char *tab;
void *udata;
{
char *key;
int key_len;
return (0);
return (0);
/*
* Wildcard entry should be ignored - following entries should continue
* to be read to corroborate with the way we search for entries in
* NIS+, i.e., first for an exact key match and then a wildcard
* if there's no exact key match.
*/
return (0);
return (1);
}
return (0);
}