[Previous] [Contents] [Next]

initgroups()

Initialize the supplementary group access list

Synopsis:

#include <grp.h>
#include <sys/types.h>

int initgroups( const char * name,
                gid_t basegid );

Library:

libc

Description:

The initgroups() function reads the group membership for the user specified by name from the group database, and then initializes the supplementary group access list of the calling process (see getgrnam() and getgroups()).

If the number of groups in the supplementary access list exceeds NGROUPS_MAX, the extra groups are ignored.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EPERM
The caller isn't root.

Files:

/etc/group
The group database.

Classification:

Unix

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread No

Caveats:

If initgroups() fails, it doesn't change the supplementary group access list.

The getgrouplist() function called by initgroups() is based on getgrent(). If the calling process uses getgrent(), the in-memory group structure is overwritten in the call to initgroups().

See also:

getgroups(), getgrnam()


[Previous] [Contents] [Next]