initgroups.3c (2010 09)

i
initgroups(3C) initgroups(3C)
NAME
initgroups( ) - initialize group access list
SYNOPSIS
#include <unistd.h>
int initgroups(const char *name, gid_t basegid);
DESCRIPTION
initgroups() reads the login group file, /etc/logingroup
, and sets up the group access list for
the user specified by name, using the
setgroups() system call (see setgroups (2)). If the value of base-
gid is zero or positive, it is automatically included in the groups list. Typically this value is given as the
group number from the password file. If the login group file is empty, basegid is the only member of the
list. If the number of groups, including the basegid entry, exceeds {NGROUPS_MAX}, then subsequent
group entries are ignored (see limits (5)).
RETURN VALUE
Upon successful completion,
initgroups() returns 0; otherwise it returns −1 and sets
errno to indi-
cate the error.
ERRORS
initgroups() fails if any of the following conditions are encountered:
[EPERM] The calling process does not have the appropriate privilege.
[ENOMEM] Insufficient memory available to hold gidset.
[EINVAL] An entry in gidset is not a valid group ID.
WARNINGS
initgroups() uses the routines based on getgrent (3C). If the invoking program uses any of these rou-
tines, the group structure is overwritten by the call to initgroups(). Subsequent calls to init-
groups() with the same name parameter override the actions of previous calls.
On many systems, no one seems to keep
/etc/logingroup
up to date.
initgroups() uses the Dynamic Name Service Switch. (See nsswitch.conf(4).) An application that
uses this interface cannot be fully archive bound.
NETWORKING FEATURES
NFS
If
/etc/logingroup
is linked to /etc/group, initgroups() tries to use the Network Informa-
tion Service (NIS) for entries beginning with a plus sign (
+). If group membership for name is managed
by NIS, and no NIS server is able to respond, a call to
initgroups() does not return until a server
does respond. This lack of action causes commands such as login and su to wait indefinitely.
See group (4) for proper syntax and operation.
AUTHOR
initgroups() was developed by the University of California, Berkeley.
FILES
/etc/logingroup login group file
SEE ALSO
login(1), su(1), getgroups(2), setgroups(2), group(4), thread_safety(5).
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1