home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.bugs.misc
- Path: sparky!uunet!spool.mu.edu!agate!ames!pacbell.com!j4jbail
- From: j4jbail@srv.PacBell.COM (Jack Bailey)
- Subject: Bug in initgroups() when using /usr/5bin/cc (SunOS)
- Message-ID: <1993Jan7.011605.2462@PacBell.COM>
- Sender: news@PacBell.COM (Pacific Bell Netnews)
- Organization: Pacific * Bell
- Distribution: usa
- Date: Thu, 7 Jan 1993 01:16:05 GMT
- Lines: 41
-
- (My apologies if this one is already well known)
-
- The following program demomstrates a bug on SunOS 4.1.2. The
- initgroups() library call fails to set the groups properly when a
- program calling it is made with /usr/5bin/cc. It works okay when
- compiled with /bin/cc.
-
- My guess to the cause of the problem has to do with the arugument
- types passed to getgroups() from within initgroups(). The SystemV
- synopsis calls for arguments of type gid_t (unsigned short); otherwise
- the args would be ints.
-
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <pwd.h>
-
- main()
- {
- struct passwd *pwd, *getpwnam();
-
- if((pwd = getpwnam("j4jbail")) == NULL) {
- printf("getpwnam() failed\n");
- exit(1);
- }
-
- system("id");
-
- if(initgroups(pwd->pw_name, pwd->pw_gid) < 0) {
- printf("initgroups() failed\n");
- exit(1);
- }
-
- system("id");
-
- exit(0);
- }
-
- --
- J.J.Bailey j4jbail@srv.pacbell.com
- Contractor 510.823.6453
-