Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jul 2010 15:29:44 +0530
From:      ashish@freebsd.org (Ashish SHUKLA)
To:        Jens Rehsack <rehsack@googlemail.com>
Cc:        Dan Nelson <dnelson@allantgroup.com>, freebsd-questions@freebsd.org
Subject:   Re: getpwent bug?
Message-ID:  <86wrsvpx0v.fsf@chateau.d.if>
In-Reply-To: <4C402689.7070005@netbsd.org> (Jens Rehsack's message of "Fri, 16 Jul 2010 09:29:45 %2B0000")
References:  <AANLkTin5RGYfu_Xt5HWxKFO8GMTOi3YWQ8dyr95ZDW-Y@mail.gmail.com> <20100715172615.GC5485@dan.emsphone.com> <86tyo0qd19.fsf@chateau.d.if> <20100716043056.GF5485@dan.emsphone.com> <AANLkTilSum3vumQhv4qtOQhCaSHo832Ub3b9bEhP0zSt@mail.gmail.com> <86d3unrfgu.fsf@chateau.d.if> <4C401B31.4000402@netbsd.org> <8639vjrdru.fsf@chateau.d.if> <4C402689.7070005@netbsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Jens Rehsack writes:
> On 07/16/10 09:12, Ashish SHUKLA wrote:
>> Jens Rehsack writes:
>>=20
>> [...]
>>=20
>>> I cached the entires - I rate setpwent as to dangerous.
>>=20
>> 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 caus=
es
|      getpwent() to ``rewind'' to the beginning of the database.  Addition=
ally,
|      if stayopen is non-zero, file descriptors are left open, significant=
ly
|      speeding up subsequent accesses for all of the routines.  (This latt=
er
|      functionality is unnecessary for getpwent() as it does not close its=
 file
|      descriptors by default.)
|=20
|      It is dangerous for long-running programs to keep the file descripto=
rs
|      open as the database will become out of date if it is updated while =
the
|      program is running.
|=20
|      The setpwent() function is identical to setpassent() with an argumen=
t 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
=2D-=20
Ashish SHUKLA      | GPG: F682 CDCC 39DC 0FEA E116  20B6 C746 CFA9 E74F A4B0
freebsd.org!ashish | http://people.freebsd.org/~ashish/

=E2=80=9CAge is not an accomplishment, and youth is not a sin.=E2=80=9D (Ro=
bert
A. Heinlein, "Methuselah's Children", 1958)

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)

iQIcBAEBCgAGBQJMQC2TAAoJEMdGz6nnT6Swv1cQAKFCiOm2ICatdQ1avmI0vfvE
IkrDJVYikM7P96TY4Chp30IpiwnMbt+YwR66XKdIr3VJU9PbHAtmfyN9PS8EwbfX
O+MeeKNgi946clJtOLJQxoeT3AtSdzmIyX8e4cpGa18FKWOP8I/5hXNSDhtlTAQN
gCaD1DhbjbcQihPk4BIiik5/CT59eE155YnukoUQWiH0zmto0PQeHRnK89CaliCN
RTkr7V0UAxfqMStcX86C0VgQ/qvQZvSXb7GxtuM1XDVnGZ6SECC85azFvzDmI7De
CU1z+Vwa5+T/ZTdHFHTSajpFR/7SP41QhXrgSI330UnxX/cReIyJYTaVA56KXZVX
Gy/H385bP1PtWVBK2ADceDTq3Pk3NMEVKDwUpQZSVQuUQreP1ilw6PPZC1h5Vcmv
LU0CHePYgdycch3hO7hNr0ZmsQK90Pnt8ScsTEm/psRFccNhhczdc0j1e8gpWlcT
6yc1krDWQloPYKw+lp8YR+stUb+p746CgO8GDJxWilyM1G9PtM4d7tAh15U5XTZN
j2Fyffl/d/w3jyqKu+HIj1cc5q64nftLpFg3kM4HdceNEoTB/VwzsHTpZKeI37O6
QwreFnwGeZdpVDszzmJiaqthSMun1iTXNy5nWLS1GfridFXAMSAJhqGv7aaDzfBW
S2naKF/5s6QiN6gE5QjR
=UlRB
-----END PGP SIGNATURE-----
--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86wrsvpx0v.fsf>