Subject: Re: HELP: su: setting user context: Invalid argument
To: Eric Fox <eric@fox.phoenix.az.us>
From: David Laight <david@l8s.co.uk>
List: netbsd-users
Date: 11/23/2002 15:54:34
On Sat, Nov 23, 2002 at 08:19:04AM -0700, Eric Fox wrote:
> A big "Thank you" to both Charles and Wojciech for their responses.
> 
> I did the ktrace and found the following message occured while reading
> from the NIS group table:
> 
> 	su: initgroups(root,0): Invalid argument

Interestingly the man page for initgroups says:
    If the groups database lists more than NGROUPS groups for name
    (including one for basegid), the later groups are ignored.

The code doesn't do this!
Actually there may be an 'off by one' error somewhere.
With NGROUPS = 16 (the default) this user works:

uid=2015(u2015) gid=100(users) groups=100(users),2015(g2015),2014(g2014),2013(g2013),2012(g2012),2011(g2011),2010(g2010),2009(g2009),2008(g2008),2007(g2007),2006(g2006),2005(g2005),2004(g2004),2003(g2003),2002(g2002),2001(g2001)

the next one fails in setgroups(), but all the man pages indicate
that the last group should be discarded.

    The getgrouplist() function returns -1 if the size of the group list is
    too small to hold all the user's groups.  Here, the group array will be
    filled with as many groups as will fit.

I'll dig little further :-)
(I have a long term plan to remove the NGROUPS limit)


	David

-- 
David Laight: david@l8s.co.uk