Subject: Re: CVS commit: src
To: Simon Burge <email@example.com>
From: Luke Mewburn <firstname.lastname@example.org>
Date: 04/25/1999 22:32:08
Simon Burge writes:
> Luke Mewburn wrote:
> > src/lib/libc/gen: getpwent.c
> > change getpwent() backends so that a flag (per source) is set once the
> > source has been exhausted. this allows getpwent() across multiple
> > sources (e.g, ``passwd: files nis'') to work correctly. the flags are
> > reset in setpassent()/endpwent().
> Without looking at your fix, is there scope for a user name being
> returned more that once if it exists in more than one source? Is
> there a standard for getpwent() that defines this behaviour?
The code makes no attempt *at all* to suppress duplicates.
If you specify ``files nis dns'', you will get all the entries
from `files' (in whatever order they come), then `nis' and then
From looking at the CVS history of getpwent.c and getgrent.c, it
seems that a couple of years ago when I first started playing around
with nsswitch I deliberately made getgrent() stop after the first
source, because it apparently caused problems with getgrouplist()
(see the log message for 126.96.36.199). This was probably due to the
entries being filled up with duplicates.
I'm about to convert getgrent() to behave the same was as getpwent()
now does, and to ensure that stuff that uses getgrent() to build the
group list does the right thing and suppresses duplicates.
PS: The man page for getpwent(3) says: ``The routines getpwent [...]
are fairly useless in a networked environment and should be
avoided, if possible.''. This comment has been there since revision
1.1 of the manual page :-)