getpwent bug?

Jens Rehsack rehsack at
Fri Jul 16 10:22:04 UTC 2010

On 07/16/10 09:59, Ashish SHUKLA wrote:
> Jens Rehsack writes:
>> On 07/16/10 09:12, Ashish SHUKLA wrote:
>>> Jens Rehsack writes:
>>> [...]
>>>> I cached the entires - I rate setpwent as to dangerous.
>>> dangerous ? why ?
>> Because it modifies something - and I might not know the source.
>> getpwent(3) delivers entries from yp, too (or LDAP) etc. - and
>> when I call setpwent(3) for such an entry, what happens then?
>> Long explanation for: I do not know the consequences - and that's
>> why I rate it dangerous as workaround.
> ,---- an excerpt from getpwent(3)
> `----
> I can't see anything which says about modifying NSS database. AFAIK none of
> the NSS routines allow you to write on database, you've to use the database
> specific method to modify the database.

You're absolutely right - I never took a deeper look, because I always
was only interested to read the (user|group) data and expected setpwent
to modify such an entry.

A quick look into Stevens "Advanced Programming in the UNIX environment"
could had enlighten myself. Sorry that I didn't RTFM carefully.

Best regards and many, many thanks,

More information about the freebsd-questions mailing list