🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #1061

Re: getgrnam(3) bug

#1061
From: Jeff Forys
Date: Sun, 15 May 1988 03:09
42 lines
2337 bytes
In article <762@yabbie.rmit.oz> rcodi@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).

>	...but upon doing a groups(1) command it is evident that you are
>	in fact a member of the group.
>
>	ie: initgroups(3) used by /bin/login reads the entire group file
>	    and looks for all entries, but getgrnam(3) only looks for
>	    the first line.

Ah, then BSD groups(1) and initgroups(3) are broken, or at least, more
liberal than they should be.  They are using getgrent() to process thru
the entire file searching for a specific username; it was `easier' to
not remember duplicate group entries and invalidate them.

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

Use another editor.

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

Awful static limitations which you arent addressing here.  The BUFSIZ
limitation can be resolved by doing block fread()'s and parsing thru
end-of-line.  The MAXGRP define can be raised if necessary, but if your
group is that big, consider using the gid field in "/etc/passwd".  You
need not match the gid field in "/etc/passwd" with a per user entry in
"/etc/group" for it to be effective.
---
Jeff Forys @ UC/Boulder Engineering Research Comp Cntr (303-492-4991)
forys@boulder.Colorado.EDU  -or-  ..!{ncar|nbires}!boulder!forys
Technical Details
Message-ID: <6076@sigi.Colorado.EDU>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!boulder!forys
References: <762@yabbie.rmit.oz>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!boulder!forys
From: forys@sigi.Colorado.EDU (Jeff Forys)
Newsgroups: comp.bugs.4bsd
Subject: Re: getgrnam(3) bug
Message-ID: <6076@sigi.Colorado.EDU>
Date: 15 May 88 03:09:11 GMT
References: <762@yabbie.rmit.oz>
Reply-To: forys@boulder.Colorado.EDU (Jeff Forys)
Organization: University of Colorado, Boulder
Lines: 41