Subject: getpwnam(3) and getting a users home directory
To: None <>
From: Anders Dinsen <>
List: netbsd-users
Date: 03/17/2001 22:46:46
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? :-)

- Anders

Anders Dinsen