getpwent bug?

Ashish SHUKLA ashish at freebsd.org
Fri Jul 16 09:59:58 UTC 2010


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)
|      The setpassent() function accomplishes two purposes.  First, it causes
|      getpwent() to ``rewind'' to the beginning of the database.  Additionally,
|      if stayopen is non-zero, file descriptors are left open, significantly
|      speeding up subsequent accesses for all of the routines.  (This latter
|      functionality is unnecessary for getpwent() as it does not close its file
|      descriptors by default.)
| 
|      It is dangerous for long-running programs to keep the file descriptors
|      open as the database will become out of date if it is updated while the
|      program is running.
| 
|      The setpwent() function is identical to setpassent() with an argument of
|      zero.
`----

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.

HTH
-- 
Ashish SHUKLA      | GPG: F682 CDCC 39DC 0FEA E116  20B6 C746 CFA9 E74F A4B0
freebsd.org!ashish | http://people.freebsd.org/~ashish/

“Age is not an accomplishment, and youth is not a sin.” (Robert
A. Heinlein, "Methuselah's Children", 1958)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20100716/5cf5be91/attachment.pgp


More information about the freebsd-questions mailing list