COHERENT manpages

This page displays the COHERENT manpage for initgroups() [Initialize the supplementary group-access list].

List of available manpages
Index


initgroups() -- General Function (libc)

Initialize the supplementary group-access list
#include <sys/types.h>
#include <grp.h>
int initgroups(user, basegid)
const char *user; gid_t basegid;

The  ``supplemental group-access  list'' is the  list of  group identifiers
that  are  used  in   addition  to  the  effective  group  identifier  when
determining the level of access that a process has to a file.  The function
initgroups() initializes  the supplemental group-access list  to the groups
to which user belongs.

user is  the login identifier of the user  in question.  basegid identifies
that user's base group, as  set in the file /etc/passwd. initgroups() calls
the library  function getgrent() to read from /etc/group  all of the groups
to  which user  belongs (in  addition to  her base  group).  It  then calls
setgroups()  to initialize  the supplementary  group-access list  to user's
base group and the additional groups returned by getgrent().

If all goes well, initgroups() modifies the supplementary group-access list
returns zero.  Otherwise, it does not modify the list, returns -1, and sets
errno to an appropriate value.

See Also

getgrent(),
libc,
setgroups()

Notes

If user  belongs to more  than NGROUPS_MAX groups,  initgroups() reads only
the first NGROUPS_MAX groups from /etc/group and ignores all of the others.
Note that NGROUPS_MAX  is a limit set by the  POSIX Standard.  For a fuller
discussion  of these  limits,  see the  Lexicon entries  for sysconf()  and
limits.h.

Only the superuser root can use initgroups().