Subject: Re: getpwnam(3) and getting a users home directory
To: Anders Dinsen <email@example.com>
From: Luke Mewburn <firstname.lastname@example.org>
Date: 03/18/2001 10:05:28
On Sat, Mar 17, 2001 at 10:46:46PM +0100, Anders Dinsen wrote:
> I want to find the home directory of a user, and my intention is to use
> getpwnam(). But the man page says (under BUGS):
> The functions getpwent(), endpwent(), setpassent(), and setpwent()
> are fairly useless in a networked environment and should be avoided,
> if possible. getpwent() makes no attempt to suppress duplicate
> information if multiple sources are specified in nsswitch.conf(5)
> Why are they useless? Because of NIS? What is the safe way to retreive a
> users home directory then?
> /usr/src/bin/csh/file.c uses getpwnam() to expand ~user, so it can't be
> that bad, I guess... Also, /usr/src/lib/libc/gen/getpwent.c seems to
> handle nsswitch as well as yp, so to me, the notice seems pretty bogus.
> Anyone knowing the truth about this? :-)
getpwnam() != getpwent(). The notice is relatively accurate.