#include <sys/types.h> #include <grp.h> struct group *getgrnam(const char *name);
getgrnam
returns a pointer to a group
structure defined
in <grp.h>
that contains an entry from the group database.
name
is the entry. group
contains the following members:
gr_name
gr_gid
gr_mem
getgrnam
returns a pointer to a group
structure if
successful.
Note that the pointer returned by
getgrnam
may be a static data area that can be rewritten by the
next call to getgrgid
or getgrnam
.
getgrnam
returns a NULL
pointer if unsuccessful.
getgrnam
to obtain a list of group members:
#include <sys/types.h> #include <stdio.h> #include <grp.h> #include <sys/stat.h> . . . struct group *grp; char grpname[]="BILLING"; char **gmem; . . . if ((grp = getgrnam(grpname)) == NULL) perror("getgrnam() error"); else { printf("These are the members of group %s:\n", grpname); for (gmem=grp->gr_mem; *gmem != NULL; gmem++) printf(" %s\n", *gmem); } . . .
getgrgid
, getpwnam
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.