getgrnam(3) bug

Ian Donaldson rcodi at yabbie.rmit.oz
Tue May 17 10:51:56 AEST 1988


>From article <6076 at sigi.Colorado.EDU>, by forys at sigi.Colorado.EDU (Jeff Forys):
> In article <762 at yabbie.rmit.oz> rcodi at yabbie.rmit.oz (Ian Donaldson) writes:
>> Description:
>>	getgrnam(3) fails to read 2nd and subsequent lines of a
>>	multi-line group specification.
> 
> That isnt the way getgrnam(3) is defined to work in either SVID or
> BSD UNIX.  "Getgrnam searches from the beginning of the file until
> a group name matching `name' is found and returns a pointer to the
> particular structure in which it was found."  Each group is separated
> from the next by a newline.  I assume POSIX defines getgrnam(3)
> similarly (I dont have a draft handy, so correct me if I'm wrong).

If this is the case, then the definition of the group file is severely
broken, and should be revised.  Having just 1 line per group is a bit
silly in a large user base environment.

>>	if you have as many people in a group that your favourite editor
>>	won't let fit onto a single line;
> 
> Use another editor.

Get serious!  The groups file is meant to be a text file.  It should
be editable by a text editor.  Any text editor!  If it can't be edited
by any text editor then it is seriously in doubt of being a text file.
 
>>	or if the line exceeds BUFSIZ (1024) characters,

not a problem if the file is a text file

>>	or if the number of members of a group on a single line
>>	exceeds 200 (see getgrent.c)

not a problem if the file is a text file

>  group is that big, consider using the gid field in "/etc/passwd". 

It may be possible in some cases to do this, but in lots this would
not be a solution.

For goodness sakes, fixing getgrnam(3) to scan for all possible group
entries is hardly going to break any software is it?  All software
reading the groups file is supposed to use the getgr*(3) routines anyway.

getpwuid(3) and getpwnam(3) already don't do sequential searches of 
/etc/passwd in 4.3bsd, with the advent of the parallel random passwd database.
The only reason that /etc/group hasn't followed suit is probably because
it never gets big enough to warrant the overheads of database lookup.

Ian D



More information about the Comp.bugs.4bsd.ucb-fixes mailing list