home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / bugs / misc / 174 next >
Encoding:
Text File  |  1993-01-06  |  1.3 KB  |  53 lines

  1. Newsgroups: comp.bugs.misc
  2. Path: sparky!uunet!spool.mu.edu!agate!ames!pacbell.com!j4jbail
  3. From: j4jbail@srv.PacBell.COM (Jack Bailey)
  4. Subject: Bug in initgroups() when using /usr/5bin/cc (SunOS)
  5. Message-ID: <1993Jan7.011605.2462@PacBell.COM>
  6. Sender: news@PacBell.COM (Pacific Bell Netnews)
  7. Organization: Pacific * Bell
  8. Distribution: usa
  9. Date: Thu, 7 Jan 1993 01:16:05 GMT
  10. Lines: 41
  11.  
  12. (My apologies if this one is already well known)
  13.  
  14. The following program demomstrates a bug on SunOS 4.1.2.  The
  15. initgroups() library call fails to set the groups properly when a
  16. program calling it is made with /usr/5bin/cc.  It works okay when
  17. compiled with /bin/cc.
  18.  
  19. My guess to the cause of the problem has to do with the arugument
  20. types passed to getgroups() from within initgroups().  The SystemV
  21. synopsis calls for arguments of type gid_t (unsigned short); otherwise
  22. the args would be ints.
  23.  
  24.  
  25. #include <stdio.h>
  26. #include <sys/types.h>
  27. #include <pwd.h>
  28.  
  29. main()
  30. {
  31.     struct    passwd *pwd, *getpwnam();
  32.  
  33.     if((pwd = getpwnam("j4jbail")) == NULL) {
  34.         printf("getpwnam() failed\n");
  35.         exit(1);
  36.     }
  37.  
  38.     system("id");
  39.  
  40.     if(initgroups(pwd->pw_name, pwd->pw_gid) < 0) {
  41.         printf("initgroups() failed\n");
  42.         exit(1);
  43.     }
  44.  
  45.     system("id");
  46.  
  47.     exit(0);
  48. }
  49.  
  50. -- 
  51. J.J.Bailey    j4jbail@srv.pacbell.com
  52. Contractor    510.823.6453
  53.