Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > I


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


initgroups() — initialize group access list


#include <unistd.h>

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


initgroups() reads the login group file, /etc/logingroup, and sets up the group access list for the user specified by name, using the setgroups(2) system call. If the value of basegid 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.


initgroups() returns -1 if it was not invoked by a user with appropriate privileges.


initgroups() uses the routines based on getgrent(3C). If the invoking program uses any of these routines, the group structure is overwritten by the call to initgroups(). Subsequent calls to initgroups() 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.



If /etc/logingroup is linked to /etc/group, initgroups() tries to use the Network Information 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 causes commands such as login(1) and su(1) to wait indefinitely.

See group(4) for proper syntax and operation.


initgroups() was developed by the University of California, Berkeley.



login group file

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.