home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi
- Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!rblander
- From: rblander@math.uwaterloo.ca (Robyn Landers)
- Subject: initgroups(3) return codes
- Message-ID: <BuDr4r.IHD@math.uwaterloo.ca>
- Organization: University of Waterloo
- Distribution: na
- Date: Thu, 10 Sep 1992 20:48:26 GMT
- Lines: 49
-
-
- The man page for initgroups says
-
- initgroups returns 0 if successful. If the calling routine doesn't have
- superuser privileges, it returns -1 and an error code is stored in global
- integer errno. If the specified user is a member of too many groups, the
- process is initialized with the maximum-allowed groups: the remaining
- groups are silently discarded by the system. A special situation occurs
- when initgroups is called on systems with multiple groups disabled (i.e.,
- ngroups_max in </usr/sysgen/master.d/kernel> set to 0): in this case
- initgroups returns -1 and errno is set to EINVAL.
-
- but it really returns the number of groups to which the user belongs.
- This is the case on both 4.0.2 and 4.0.4, regardless of BSD version
- and flags or not.
-
- Gory details below:
-
- parsley 17# more test.c
- #include <unistd.h>
- #include <sys/types.h>
- #include <errno.h>
-
- main() {
- auto int status;
-
- system("groups");
-
- errno = 0;
- status = initgroups("rbutterw", 10);
-
- printf("initgroups(\"rbutterw\", 10) returned %d, errno=%d\n",
- status, errno);
-
- system("groups");
-
- exit(0);
- }
- parsley 18# cc test.c
- parsley 19# ./a.out
- sys daemon bin adm mail dumpster
- initgroups("rbutterw", 10) returned 3, errno=0
- nuucp accounts other
-
-
-
- -----
- Robyn Landers rblanders@math.uwaterloo.ca
- MFCF, University of Waterloo
-