Philip Hazel writes:
>
> If people could try this out as root on various other OS, I'd be
> grateful. Please post the results to save too many people doing it.
OK:
# uname -a
NetBSD skutter 1.2D NetBSD 1.2D (SKUTTER) #53: Wed Apr 2 18:43:03 BST 1997 root@skutter:/usr/src/sys/arch/i386/compile/SKUTTER i386
# ./test
count = 7
0 2 3 4 5 20 31
setgroups(0,NULL) succeeded
count = 0
gid = 8
count = 0
#
Looks like the setgroups() call succeeds under NetBSD. Perhaps some
#ifdef guards would be more appropriate, instead of attempting the
setgroups(0,NULL) on all platforms.
> Philip
Cheers Scott
PS setgroups manpage attached from NetBSD-current
--
Scott Stevens, Network Services Group, Computer Centre, Imperial College
"I just don't trust that machine, man. Look, I know it's old-fashioned,
but I'm from the school that believes, "If God intended us to fly, he
wouldn't have invented Spanish air traffic control"." - Lister, Red Dwarf
--- cut here ---
SETGROUPS(2) NetBSD Programmer's Manual SETGROUPS(2)
NAME
setgroups - set group access list
SYNOPSIS
#include <sys/param.h>
#include <unistd.h>
int
setgroups(int ngroups, const gid_t *gidset)
DESCRIPTION
Setgroups() sets the group access list of the current user process ac-
cording to the array gidset. The parameter ngroups indicates the number
of entries in the array and must be no more than {NGROUPS_MAX}.
Only the super-user may set new groups.
RETURN VALUES
A 0 value is returned on success, -1 on error, with an error code stored
in errno.
ERRORS
The setgroups() call will fail if:
[EINVAL] The value of ngroups is greater than {NGROUPS_MAX}.
[EPERM] The caller is not the super-user.
[EFAULT] The address specified for gidset is outside the process ad-
dress space.
SEE ALSO
getgroups(2), initgroups(3)
HISTORY
The setgroups() function call appeared in 4.2BSD.
4.2 Berkeley Distribution February 11, 1997 1
--- cut here ---