This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

initgroups()



Small problem with initgroups():

misiek@dark misiek$ rpm -q glibc gcc
glibc-2.1.2-13
gcc-2.95.2-1
misiek@dark misiek$ LC_ALL=C id
uid=1000(misiek) gid=1000(users) groups=1000(users)
misiek@dark misiek$ gcc test.c -Wall -o test && LC_ALL=C ./test
initgroups("misiek", -1)
error Invalid argument
misiek@dark misiek$

AFAIK this should work ...

#include <stdio.h>
#include <unistd.h>
#include <grp.h>
#include <pwd.h>
#include <sys/types.h>

int main()
{
	int ret;
	struct passwd *pw;
	pw = getpwuid(getuid());
	printf("initgroups(\"%s\", -1)\n",pw->pw_name);
	ret = initgroups(pw->pw_name, -1);
	if (ret < 0)
		printf("error %m\n");
	else
		printf("OK\n");
	return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]