home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13497 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.7 KB  |  60 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!rblander
  3. From: rblander@math.uwaterloo.ca (Robyn Landers)
  4. Subject: initgroups(3) return codes
  5. Message-ID: <BuDr4r.IHD@math.uwaterloo.ca>
  6. Organization: University of Waterloo
  7. Distribution: na
  8. Date: Thu, 10 Sep 1992 20:48:26 GMT
  9. Lines: 49
  10.  
  11.  
  12. The man page for initgroups says
  13.  
  14.      initgroups returns 0 if successful.  If the calling routine doesn't have
  15.      superuser privileges, it returns -1 and an error code is stored in global
  16.      integer errno.  If the specified user is a member of too many groups, the
  17.      process is initialized with the maximum-allowed groups: the remaining
  18.      groups are silently discarded by the system.  A special situation occurs
  19.      when initgroups is called on systems with multiple groups disabled (i.e.,
  20.      ngroups_max in </usr/sysgen/master.d/kernel> set to 0): in this case
  21.      initgroups returns -1 and errno is set to EINVAL.
  22.  
  23. but it really returns the number of groups to which the user belongs.
  24. This is the case on both 4.0.2 and 4.0.4, regardless of BSD version
  25. and flags or not.
  26.  
  27. Gory details below:
  28.  
  29. parsley 17# more test.c
  30. #include <unistd.h>
  31. #include <sys/types.h>
  32. #include <errno.h>
  33.  
  34. main() {
  35.         auto int status;
  36.  
  37.         system("groups");
  38.  
  39.         errno = 0;
  40.         status = initgroups("rbutterw", 10);
  41.  
  42.         printf("initgroups(\"rbutterw\", 10) returned %d, errno=%d\n",
  43.                 status, errno);
  44.  
  45.         system("groups");
  46.  
  47.         exit(0);
  48. }
  49. parsley 18# cc test.c
  50. parsley 19# ./a.out
  51. sys daemon bin adm mail dumpster
  52. initgroups("rbutterw", 10) returned 3, errno=0
  53. nuucp accounts other
  54.  
  55.  
  56.  
  57. -----
  58. Robyn Landers    rblanders@math.uwaterloo.ca
  59. MFCF, University of Waterloo
  60.