Initialize the supplementary group access list
#include <grp.h> #include <sys/types.h> int initgroups( const char * name, gid_t basegid );
- The name of the user whose group membership you want to use as the supplementary group access list.
- A group ID that you want to include in the group access list.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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.
- An error occurred (errno is set).
- The caller isn't root.
- The group database.
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().