getgroups() gives wrong result with nss_winbind

Andreas andreas at
Fri Sep 17 17:16:55 GMT 2004

On Fri, Sep 17, 2004 at 11:59:04PM +1000, tridge at wrote:
> I'd be interested in seeing what arguments are being passed to 
> _nss_winbind_initgroups_dyn() for your test program. 
> That function looks like this:
> _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
> 			    long int *size, gid_t **groups, long int limit,
> 			    int *errnop);

*size = 64
*start = 1
limit = 65536

> notice the "limit" and "*size" arguments? Those are what limits this
> function to a particular number of groups. Maybe glibc is calling it
> with a small limit first, and expecting some specific error code or
> other indicator in order to continue?

Yes about the "small size first"

> At this stage I'd start adding debug code to
> _nss_winbind_initgroups_dyn() in source/nsswitch/winbind_nss_linux.c
> and see if you can spot whats going on.

Basically, glibc's initgroups() chooses size so that:

long int limit = __sysconf (_SC_NGROUPS_MAX);
size = MIN (limit, 64);

Which ends up being 64 in my case and then calls _nss_winbind_initgroups_dyn with
these parameters. I'm trying to make _nss_winbind_initgroups_dyn return with
errnop = ERANGE and NSS_TRYAGAIN but it isn't working.

More information about the samba-technical mailing list