🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Jack Bailey Thu, 07 Jan 1993 01:16
Bug in initgroups() when using /usr/5bin/cc (SunOS)
#46
Author: Jack Bailey
Date: Thu, 07 Jan 1993 01:16
41 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads