FreeBSD/sys/kern/kern_proc.c
/*
 * This sysctl allows a process to retrieve the full list of groups from
 * itself or another process.
 */
This sysctl allows a process to retrieve the full list of groups from
itself or another process.
This sysctl allows a process to retrieve the full list of groups from itself or another process .
static int
sysctl_kern_proc_groups(SYSCTL_HANDLER_ARGS)
{
	pid_t *pidp = (pid_t *)arg1;
	unsigned int arglen = arg2;
	struct proc *p;
	struct ucred *cred;
	int error;
	if (arglen != 1)
		return (EINVAL);
	if (*pidp == -1) {	
		p = req->td->td_proc;
		PROC_LOCK(p);
	} else {
		error = pget(*pidp, PGET_CANSEE, &p);
		if (error != 0)
			return (error);
	}
	cred = crhold(p->p_ucred);
	PROC_UNLOCK(p);
	error = SYSCTL_OUT(req, cred->cr_groups,
	    cred->cr_ngroups * sizeof(gid_t));
	crfree(cred);
	return (error);
}
static int sysctl_kern_proc_groups ( SYSCTL_HANDLER_ARGS ) { pid_t * pidp = ( pid_t * ) arg1 ; unsigned int arglen = arg2 ; struct proc * p ; struct ucred * cred ; int error ; if ( arglen != 1 ) return ( EINVAL ) ; if ( * pidp == -1 ) { p = req -> td -> td_proc ; PROC_LOCK ( p ) ; } else { error = pget ( * pidp , PGET_CANSEE , & p ) ; if ( error != 0 ) return ( error ) ; } cred = crhold ( p -> p_ucred ) ; PROC_UNLOCK ( p ) ; error = SYSCTL_OUT ( req , cred -> cr_groups , cred -> cr_ngroups * sizeof ( gid_t ) ) ; crfree ( cred ) ; return ( error ) ; }
This sysctl allows a process to retrieve the full list of groups from
 itself or another process.
This sysctl allows a process to retrieve the full list of groups from itself or another process .
/* -1 means this process */