Subject: implementing a name service switch...
To: None <tech-net@netbsd.org>
From: Luke Mewburn <lm@melb.cpr.itg.telecom.com.au>
List: tech-net
Date: 12/06/1994 12:40:28
A feature I appreciate in Solaris and ULTRIX is the concept of a name
service switch. Before I go and hack away at implementing this ad-hoc,
I thought I'd pass the idea past other users and the core team to
improve the chances of the code being made standard NetBSD.

Basically, a config file such as /etc/nsswitch.conf (for name
compatibility with Solaris, HPUX, and probably every other SVR4) is
required. Then, for each database such as passwd, group, netgroup,
hosts, services, etc, there is an entry describing the lookup
procedure from various sources such as local (files), bind, yp,
or any other transport mechanism we provide.

A way of implementing the various functions such as getpwnam(),
getservbyname(), innetgr(), etc could be to have these implemented
as stub functions which call a dispatch routine. That routine
would build up an array of databases and the names of local funcs
to call depending upon service This array, of course, would only
be rebuilt on first use or when nsswitch.conf has changed.
Certain functions always call the local or the bind version first,
or can, with certain options, be set to return `failure' on
checking a certain service and getting no result (e.g, don't
check local files if YP is down, only if YP is unavailable.)
For more info, check out the man for nsswitch.conf on Solaris 2
(I'd mail it but I don't know the copyright problems with this...)

For now, the following sources would be available:
	bind		dns for hosts, and passwd/group stuff via HESIOD
	YP		yp.
	local		/etc/hosts, etc

The following databases (at least) would be available:
	database	services
	--------	--------
	hosts		bind,yp,local
	networks	bind,yp,local
	services	bind,yp,local
	protocols	bind,yp,local
	passwd		bind,yp,local
	group		bind,yp,local
	netgroup	yp,local
	aliases		bind,yp,local

Of course, this would mean that HESIOD access functions would have
to be obtained/written... Also, I notice that recently Christos Zoulas
has improved netgroup support, including allowing for local file
access. This is a Good Thing. I wish everyone else had local (I.e,
non-YP netgroups.) Especially Sun on Solaris 2 'cause YP and NIS+ are
both broken... 


Anyway, before I commit myself to this task, I'm asking for comments
from others.


PS: I know that NetBSD's resolv.conf has been hacked to support
this to some extent, but if we codified a more generic scheme that
was independant of the BIND sources, a standard BIND could be
installed without merging local NetBSD changes in. Also, I can see
the difficulties in maintaining libc when it's littered with
#ifdef YP or #ifdef DNS or whatever in functions like getpwuid,
getgrnam, gethostbyname, etc, everytime a new database source
was implemented...


-- 
Luke Mewburn, <lm@cpr.itg.telecom.com.au>
`Think of it as Evolution in Action.' - "Oath of Fealty", Niven & Pournelle