[comp.sys.next] getpwnam on the NeXT

eps@toaster.SFSU.EDU (Eric P. Scott) (06/17/91)

In article <3NG-_4-@engin.umich.edu> cerberus@geo.lsa.umich.edu
	(R. Eric Bennett) writes:
>Is there an equivalent funtion for getpwnam() on the NeXT? getpwname() returns
>a structure according to a login name by reading the passwd file.  Of course,
>thanks to NetInfo, /etc/passwd doesn't have any valid users.  How do I get the
>user's info since it can't be looked up in the passwd file?

You're confused.  getpwnam() on the NeXT knows about NetInfo and
YP/NIS, and does "the right thing."  *DO NOT* attempt to read
/etc/passwd directly nor use getpw()--stick with getpwnam() and
getpwuid().  If you use setpwfile(), all bets are off.

					-=EPS=-

Lovstrand@EuroPARC.Xerox.COM (Lennart Lovstrand) (06/17/91)

In article <3NG-_4-@engin.umich.edu> cerberus@geo.lsa.umich.edu (R. Eric  
Bennett) writes:
> Is there an equivalent funtion for getpwnam() on the NeXT? getpwname()
> returns a structure according to a login name by reading the passwd file.
> Of course, thanks to NetInfo, /etc/passwd doesn't have any valid users.
> How do I get the user's info since it can't be looked up in the passwd file?

You use getpwnam().  Seriously, getpwnam() is _the_ generic interface to use
to find out passwd information about any user that is known to your system.
It doesn't matter if your machine uses /etc/passwd, NetInfo or Yellow Pages  
(ugh, I mean NIS), the same function applies to all of them.  (Of course, if  
you do use NetInfo, then /etc/passwd is ignored just as you said yourself.)

By the way, the same applies to getgrent(), gethostbyname(), getservbyname(),  
etc.  [NeXT Mach 2.1]

Cheers,
--
--Lennart <Lovstrand@EuroPARC.Xerox.COM>		R   _A _  N_   K
Rank Xerox EuroPARC, 61 Regent St, Cambridge, UK	\/ |_ |_) | | \/
Heart-of-Gold, NeXTcube at EuroPARC, NeXT Mach 2(1)	/\ |_ | \ |_| /\
TOPS-20 Command processor 7(109)-8 [alpha]		E u r o  P A R C

nerd@percival.rain.com (Michael Galassi) (06/17/91)

eps@toaster.SFSU.EDU (Eric P. Scott) writes:

>You're confused.  getpwnam() on the NeXT knows about NetInfo and
>YP/NIS, and does "the right thing."  *DO NOT* attempt to read
>/etc/passwd directly nor use getpw()--stick with getpwnam() and
>getpwuid().  If you use setpwfile(), all bets are off.

I did some checking here, setpwfile(3) is ignored if you are doing
NetInfo, very much of a pain.  I needed this to read password files
off other machines on the network to do checking for 'obvious'
passwords.   The workaround was to convert password files to word
lists with vi <yuck>.

-m
-- 
Michael Galassi				| nerd@percival.rain.com
MS-DOS:  The ultimate PC virus.		| ...!tektronix!percy!nerd