getgraent.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 1990 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <grp.h>
#include <grpadj.h>
#include <string.h>
#include <malloc.h>
extern void rewind();
extern long strtol();
extern int fclose();
void setgraent(void);
void endgraent(void);
static struct gradata {
char *domain;
char *yp;
int yplen;
char *oldyp;
int oldyplen;
struct list {
char *name;
} *minuslist; /* list of - items */
struct group_adjunct interpgra;
struct group_adjunct *sv;
static char *GROUPADJ = "/etc/security/group.adjunct";
static struct group_adjunct *interpret(char *, int);
static struct group_adjunct *interpretwithsave(char *, int,
struct group_adjunct *);
static struct group_adjunct *getnamefromyellow(char *,
struct group_adjunct *);
static int onminuslist(struct group_adjunct *);
static int matchname(char [], struct group_adjunct **, char *);
static void freeminuslist(void);
static void getnextfromyellow(void);
static void getfirstfromyellow(void);
static void addtominuslist(char *);
static struct gradata *
_gradata(void)
{
if (g == 0) {
gradata = g;
}
return (g);
}
struct group_adjunct *
{
struct group_adjunct *gra;
setgraent();
if (g == 0)
return (0);
if (!g->grfa)
return (NULL);
continue;
endgraent();
return (gra);
}
}
endgraent();
return (NULL);
}
void
setgraent(void)
{
if (g == NULL)
return;
(void) yp_get_default_domain(&g->domain);
if (!g->grfa)
else
if (g->yp)
}
void
endgraent(void)
{
if (g == 0)
return;
if (g->grfa) {
}
if (g->yp)
}
struct group_adjunct *
fgetgraent(FILE *f)
{
return (NULL);
}
static char *
grskip(char *p, int c)
{
while(*p && *p != c && *p != '\n') ++p;
if (*p == '\n')
*p = '\0';
else if (*p != '\0')
*p++ = '\0';
return (p);
}
struct group_adjunct *
getgraent(void)
{
static struct group_adjunct *savegra;
struct group_adjunct *gra;
if (g == 0)
return (0);
(void) yp_get_default_domain(&g->domain);
}
return (NULL);
if (g->yp) {
return (NULL);
if (onminuslist(gra))
goto again;
else
return (gra);
}
return (NULL);
return (NULL);
switch(line1[0]) {
case '+':
goto again;
}
/*
* else look up this entry in NIS
*/
goto again;
else if (onminuslist(gra))
goto again;
else
return (gra);
break;
case '-':
goto again;
break;
default:
if (onminuslist(gra))
goto again;
return (gra);
break;
}
/* NOTREACHED */
}
static struct group_adjunct *
{
char *p;
if (g == 0)
return (0);
p = g->interpline;
p = grskip(p,':');
/* we are going to the NIS - fix the
* rest of the struct as much as is needed
*/
return (&g->interpgra);
}
g->interpgra.gra_passwd = p;
while(*p && *p != '\n') p++;
*p = '\0';
return (&g->interpgra);
}
static void
freeminuslist(void)
{
if (g == 0)
return;
}
}
static struct group_adjunct *
{
struct group_adjunct *gra;
if (g == 0)
return (0);
return (NULL);
return (gra);
}
static int
{
char *nm;
if (g == 0)
return (0);
return (1);
return (0);
}
static void
getnextfromyellow(void)
{
int reason;
int keylen;
if (g == 0)
return;
#ifdef DEBUG
#endif
}
if (g->oldyp)
}
static void
getfirstfromyellow(void)
{
int reason;
int keylen;
if (g == 0)
return;
#ifdef DEBUG
#endif
}
if (g->oldyp)
}
static struct group_adjunct *
{
struct group_adjunct *gra;
int reason;
char *val;
int vallen;
if (g == 0)
return (NULL);
#ifdef DEBUG
#endif
return (NULL);
}
else {
return (NULL);
return (gra);
}
}
static void
addtominuslist(char *name)
{
char *buf;
if (g == 0)
return;
}
/*
* save away psswd field, which is the only
* one which can be specified in a local + entry to override the
* value in the NIS
*/
static struct group_adjunct *
{
if (g == 0)
return (0);
/*
* free up stuff from last time around
*/
if (g->sv) {
}
return (g->sv);
}
static int
{
struct group_adjunct *savegra;
switch (line1[0]) {
case '+':
if (gra) {
return (1);
}
else
return (0);
}
if (gra) {
return (1);
}
else
return (0);
}
break;
case '-':
return (1);
}
break;
default:
return (1);
}
return (0);
}