/*
* 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.
*/
#include "lint.h"
#include <pwd.h>
#include <nss_dbdefs.h>
#include <stdio.h>
#include <synch.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int str2passwd(const char *, int, void *,
char *, int);
static DEFINE_NSS_DB_ROOT(db_root);
static DEFINE_NSS_GETENT(context);
void
{
p->name = NSS_DBNAM_PASSWD;
}
#include <getxby_door.h>
struct passwd *
int buflen);
struct passwd *
int buflen);
/*
* POSIX.1c Draft-6 version of the function getpwnam_r.
* It was implemented by Solaris 2.3.
*/
struct passwd *
{
return (NULL);
}
&arg);
}
/*
* POSIX.1c Draft-6 version of the function getpwuid_r.
* It was implemented by Solaris 2.3.
*/
struct passwd *
{
&arg);
}
struct passwd *
int buflen)
{
&arg);
}
/*
* POSIX.1c standard version of the function getpwuid_r.
* User gets it via static getpwuid_r from the header file.
*/
int
{
int nerrno = 0;
errno = 0;
== NULL) {
}
return (nerrno);
}
struct passwd *
int buflen)
{
&arg);
}
/*
* POSIX.1c standard version of the function getpwnam_r.
* User gets it via static getpwnam_r from the header file.
*/
int
{
int nerrno = 0;
errno = 0;
== NULL) {
}
return (nerrno);
}
void
setpwent(void)
{
}
void
endpwent(void)
{
}
struct passwd *
{
char *nam;
/* In getXXent_r(), protect the unsuspecting caller from +/- entries */
do {
/* No key to fill in */
}
struct passwd *
{
/* ... but in fgetXXent_r, the caller deserves any +/- entry he gets */
/* No key to fill in */
_nss_XbyY_fgets(f, &arg);
}
static char *
{
char *p = *nextpp;
char *q = p;
char c;
if (p == 0)
return (0);
while ((c = *q) != '\0' && c != ':')
q++;
if (c == '\0')
*nextpp = 0;
else {
*q++ = '\0';
*nextpp = q;
}
return (p);
}
/*
* 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.
*/
int
{
char *p, *next;
return (NSS_STR_PARSE_ERANGE);
/*
* We copy the input string into the output buffer and
* operate on it in place.
*/
/* Overlapping buffer copies are OK */
}
/* quick exit do not entry fill if not needed */
return (NSS_STR_PARSE_SUCCESS);
if (*p == '\0') {
/* Empty username; not allowed */
return (NSS_STR_PARSE_PARSE);
}
if (black_magic) {
/*
* pwconv tests pw_passwd and pw_age == NULL
*/
/*
* the rest of the passwd entry is "optional"
*/
}
if (p == 0) {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
for (; *p != '\0'; p++) { /* age */
if (*p == ',') {
*p++ = '\0';
break;
}
}
p = next; /* uid */
if (p == 0 || *p == '\0') {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
if (!black_magic) {
/*
* strtoul returns unsigned long which is
* 8 bytes on a 64-bit system. We don't want
* to assign it directly to passwd->pw_uid
* which is 4 bytes or else we will end up
* truncating the value.
*/
errno = 0;
/* uid field should be nonempty */
/* also check errno from strtoul */
return (NSS_STR_PARSE_PARSE);
}
/*
* The old code (in 2.0 through 2.5) would check
* for the uid being negative, or being greater
* than 60001 (the rfs limit). If it met either of
* these conditions, the uid was translated to 60001.
*
* Now we just check for -1 (UINT32_MAX); anything else
* is administrative policy
*/
if (tmp >= UINT32_MAX)
else
}
if (*next++ != ':') {
if (black_magic)
else
return (NSS_STR_PARSE_PARSE);
}
p = next; /* gid */
if (p == 0 || *p == '\0') {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
if (!black_magic) {
errno = 0;
/* gid field should be nonempty */
/* also check errno from strtoul */
return (NSS_STR_PARSE_PARSE);
}
/*
* gid should not be -1; anything else
* is administrative policy.
*/
if (tmp >= UINT32_MAX)
else
}
if (*next++ != ':') {
if (black_magic)
else
return (NSS_STR_PARSE_PARSE);
}
if (p == 0) {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
if (p == 0) {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
if (p == 0) {
if (black_magic)
return (NSS_STR_PARSE_SUCCESS);
else
return (NSS_STR_PARSE_PARSE);
}
/* Better not be any more fields... */
if (next == 0) {
/* Successfully parsed and stored */
return (NSS_STR_PARSE_SUCCESS);
}
return (NSS_STR_PARSE_PARSE);
}