getpwaent.c revision 5d54f3d8999eac1762fe0a8c7177d20f1f201fae
/*
* 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 1991 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <pwdadj.h>
#include <pwd.h>
#include <string.h>
#include <malloc.h>
extern void rewind();
extern long strtol();
extern int fclose();
void setpwaent(void);
void endpwaent(void);
static struct _pwajunk {
char *_yp;
int _yplen;
char *_oldyp;
int _oldyplen;
struct list {
char *name;
} *_minuslist;
struct passwd _interppasswd;
struct passwd_adjunct _apwadj;
char *_domain;
static char *PASSWDADJ = "/etc/security/passwd.adjunct";
static struct passwd_adjunct *interpret(char *, int);
static struct passwd_adjunct *interpretwithsave(char *, int,
struct passwd_adjunct *);
static struct passwd_adjunct *getnamefromyellow(char *,
struct passwd_adjunct *);
static int matchname(char [], struct passwd_adjunct **, char *);
static int onminuslist(struct passwd_adjunct *);
static void getnextfromyellow(void);
static void getfirstfromyellow(void);
static void freeminuslist(void);
static void addtominuslist(char *);
static struct _pwajunk *
_pwajunk(void)
{
if (__pwajunk == 0)
return (__pwajunk);
}
struct passwd_adjunct *
{
struct passwd_adjunct *pwadj;
if (_pwa == 0)
return (NULL);
setpwaent();
if (!pwfadj)
return (NULL);
continue;
endpwaent();
return (pwadj);
}
}
endpwaent();
return (NULL);
}
void
setpwaent(void)
{
if (_pwa == 0)
return;
(void) yp_get_default_domain(&domain );
}
else
if (yp)
}
void
endpwaent(void)
{
if (_pwa == 0)
return;
}
if (yp)
endnetgrent();
}
struct passwd_adjunct *
getpwaent(void)
{
static struct passwd_adjunct *savepwadj;
struct passwd_adjunct *pwadj;
char *user;
char *mach;
char *dom;
if (_pwa == 0)
return (NULL);
(void) yp_get_default_domain(&domain );
}
return (NULL);
}
for (;;) {
if (yp) {
return (NULL);
if (!onminuslist(pwadj)) {
return (pwadj);
}
if (user) {
return (pwadj);
}
}
} else {
endnetgrent();
return (NULL);
}
return (NULL);
switch(line[0]) {
case '+':
/* include the whole NIS database */
} else {
}
} else {
/*
* else look up this entry in NIS
*/
return (pwadj);
}
}
break;
case '-':
/* everybody was subtracted */
return (NULL);
}
if (user) {
}
}
endnetgrent();
} else {
}
break;
default:
if (!onminuslist(pwadj)) {
return (pwadj);
}
break;
}
}
}
}
static int
{
struct passwd_adjunct *savepwadj;
if (_pwa == 0)
return (0);
switch(line1[0]) {
case '+':
if (pwadj) {
return (1);
}
else
return (0);
}
if (pwadj) {
return (1);
}
}
return (0);
}
if (pwadj) {
return (1);
}
else
return (0);
}
break;
case '-':
return (1);
}
}
return (1);
}
break;
default:
return (1);
}
return (0);
}
static void
getnextfromyellow(void)
{
int reason;
char *key;
int keylen;
if (_pwa == 0)
return;
if (reason) {
#ifdef DEBUG
#endif
}
if (oldyp)
}
static void
getfirstfromyellow(void)
{
int reason;
char *key;
int keylen;
if (_pwa == 0)
return;
if (reason) {
#ifdef DEBUG
#endif
}
if (oldyp)
}
static struct passwd_adjunct *
{
struct passwd_adjunct *pwadj;
int reason;
char *val;
int vallen;
if (_pwa == 0)
return (NULL);
if (reason) {
#ifdef DEBUG
#endif
return (NULL);
} else {
return (NULL);
return (pwadj);
}
}
static struct passwd_adjunct *
{
struct passwd_adjunct *pwadj;
if (_pwa == 0)
return (NULL);
return (NULL);
return (pwadj);
}
static char *
pwskip(char *p)
{
while(*p && *p != ':' && *p != '\n')
++p;
if (*p == '\n')
*p = '\0';
else if (*p != '\0')
*p++ = '\0';
return (p);
}
static struct passwd_adjunct *
{
char *p;
char *field;
if (_pwa == 0)
return (NULL);
p = interpline;
p = pwskip(p);
/* we are going to the NIS - fix the
* rest of the struct as much as is needed
*/
return (&apwadj);
}
apwadj.pwa_passwd = p;
p = pwskip(p);
field = p;
p = pwskip(p);
field = p;
p = pwskip(p);
field = p;
p = pwskip(p);
field = p;
p = pwskip(p);
return (NULL);
field = p;
(void) pwskip(p);
p = apwadj.pwa_passwd;
while (*p && *p != ',')
p++;
if (*p)
*p = '\0';
return (NULL);
return (&apwadj);
}
static void
freeminuslist(void) {
if (_pwa == 0)
return;
}
}
static void
addtominuslist(char *name)
{
char *buf;
if (_pwa == 0)
return;
}
/*
* save away the psswd field, which is the only one which can be
* specified in a local + entry to override the value in the NIS
* for passwd.adjunct
*/
static struct passwd_adjunct *
{
static struct passwd_adjunct *sv;
if (_pwa == 0)
return (NULL);
/* free up stuff from last call */
if (sv) {
}
return (sv);
}
static int
{
char *nm;
if (_pwa == 0)
return (0);
return (1);
}
}
return (0);
}