Article View: comp.bugs.misc
Article #46Bug in initgroups() when using /usr/5bin/cc (SunOS)
From: Jack Bailey
Date: Thu, 07 Jan 1993 01:16
Date: Thu, 07 Jan 1993 01:16
41 lines
1335 bytes
1335 bytes
(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
Technical Details
Message-ID:
<1993Jan7.011605.2462@PacBell.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!ames!pacbell.com!j4jbailShow Full Headers
Complete Article Headers
Newsgroups: comp.bugs.misc Path: arc1-ca.pugleaf.net!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