getspent.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 (c) 1988-1992 Sun Microsystems Inc
* All Rights Reserved.
*
* nis/getspent.c -- "nis" backend for nsswitch "shadow" database
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <shadow.h>
#include <string.h>
#include "nis_common.h"
/*
* Most of the information in a struct spwd simply isn't available from the
* YP maps, we dummy out all the numeric fields and just get sp_namp and
* sp_pwdp (name and password) from the YP passwd map. Thus we don't
* use the str2ent() routine that's passed to us, but instead have our
* own dummy routine:
*
* Return values: 0 = success, 1 = parse error, 2 = erange ...
* The structure pointer passed in is a structure in the caller's space
* wherein the field pointers would be set to areas in the buffer if
* need be. instring and buffer should be separate areas. Let's not
* fight over crumbs.
*/
static int
const char *instr;
int lenstr;
void *ent; /* it is really (struct spwd *) */
char *buffer;
int buflen;
{
char *p, *q;
/*
* We know that instr != 0 because we're in 'nis', not 'files'
*/
return (NSS_STR_PARSE_PARSE);
}
return (NSS_STR_PARSE_PARSE);
}
/* Don't bother checking the rest of the YP passwd entry... */
return (NSS_STR_PARSE_ERANGE);
}
return (NSS_STR_PARSE_SUCCESS);
}
typedef int (*cstr2ent_t)(const char *, int, void *, char *, int);
static nss_status_t
void *a;
{
/*
* check for the C2 security flag "##" in the passwd field.
* If the first 2 chars in the passwd field is "##", get
* the user's passwd from passwd.adjunct.byname map.
* The lookup to this passwd.adjunct.byname map will only
* succeed if the caller's uid is 0 because only root user
* can use privilege port.
*/
/* get password from passwd.adjunct.byname */
"passwd.adjunct.byname",
}
return (res);
}
#define NIS_SP_GETENT
#ifdef NIS_SP_GETENT
static nss_status_t
void *a;
{
/*
* check for the C2 security flag "##" in the passwd field.
* If the first 2 chars in the passwd field is "##", get
* the user's passwd from passwd.adjunct.byname map.
* The lookup to this passwd.adjunct.byname map will only
* succeed if the caller's uid is 0 because only root user
* can use privilege port.
*/
/* get password from passwd.adjunct.byname */
"passwd.adjunct.byname",
}
return (res);
}
#endif /* NIS_SP_GETENT */
static nis_backend_op_t shadow_ops[] = {
#ifdef NIS_SP_GETENT
#else
0,
#endif /* NIS_SP_GETENT */
};
{
return (_nss_nis_constr(shadow_ops,
sizeof (shadow_ops) / sizeof (shadow_ops[0]),
"passwd.byname"));
}