FreeBSD/crypto/openssh/groupaccess.c
/*
 * Initialize group access list for user with primary (base) and
 * supplementary groups.  Return the number of groups in the list.
 */
Initialize group access list for user with primary (base) and
supplementary groups.  Return the number of groups in the list.
Initialize group access list for user with primary ( base ) and supplementary groups . Return the number of groups in the list .
int
ga_init(const char *user, gid_t base)
{
	gid_t *groups_bygid;
	int i, j;
	struct group *gr;
	if (ngroups > 0)
		ga_free();
	ngroups = NGROUPS_MAX;
#if defined(HAVE_SYSCONF) && defined(_SC_NGROUPS_MAX)
	ngroups = MAX(NGROUPS_MAX, sysconf(_SC_NGROUPS_MAX));
#endif
	groups_bygid = xcalloc(ngroups, sizeof(*groups_bygid));
	groups_byname = xcalloc(ngroups, sizeof(*groups_byname));
	if (getgrouplist(user, base, groups_bygid, &ngroups) == -1)
		logit("getgrouplist: groups list too small");
	for (i = 0, j = 0; i < ngroups; i++)
		if ((gr = getgrgid(groups_bygid[i])) != NULL)
			groups_byname[j++] = xstrdup(gr->gr_name);
	free(groups_bygid);
	return (ngroups = j);
}
int ga_init ( const char * user , gid_t base ) { gid_t * groups_bygid ; int i , j ; struct group * gr ; if ( ngroups > 0 ) ga_free ( ) ; ngroups = NGROUPS_MAX ; #if defined ( HAVE_SYSCONF ) && defined ( _SC_NGROUPS_MAX ) ngroups = MAX ( NGROUPS_MAX , sysconf ( _SC_NGROUPS_MAX ) ) ; #endif groups_bygid = xcalloc ( ngroups , sizeof ( * groups_bygid ) ) ; groups_byname = xcalloc ( ngroups , sizeof ( * groups_byname ) ) ; if ( getgrouplist ( user , base , groups_bygid , & ngroups ) == -1 ) logit ( " " ) ; for ( i = 0 , j = 0 ; i < ngroups ; i ++ ) if ( ( gr = getgrgid ( groups_bygid [ i ] ) ) != NULL ) groups_byname [ j ++ ] = xstrdup ( gr -> gr_name ) ; free ( groups_bygid ) ; return ( ngroups = j ) ; }
Initialize group access list for user with primary (base) and
 supplementary groups.
Initialize group access list for user with primary ( base ) and supplementary groups .