xref: /freebsd/share/man/man8/yp.8 (revision 952d112864d8008aa87278a30a539d888a8493cd)
1.\" Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. The name of the author may not be used to endorse or promote
13.\"    products derived from this software without specific prior written
14.\"    permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
17.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     from: @(#)yp.8	1.0 (deraadt) 4/26/93
29.\"	$Id: yp.4,v 1.11 1997/02/22 13:24:55 peter Exp $
30.\"
31.Dd April 5, 1993
32.Dt YP 4
33.Os BSD 4.2
34.Sh NAME
35.Nm yp
36.Nd description of the YP/NIS system
37.Sh SYNOPSIS
38.Nm yp
39.Sh DESCRIPTION
40The
41.Nm YP
42subsystem allows network management of passwd, group, netgroup, hosts,
43services, rpc, bootparams and ethers file
44entries through the functions
45.Xr getpwent 3 ,
46.Xr getgrent 3 ,
47.Xr getnetgrent 3 ,
48.Xr gethostent 3 ,
49.Xr getnetent 3 ,
50.Xr getrpcent 3 ,
51and
52.Xr ethers 3 .
53The
54.Xr bootparamd 8
55daemon makes direct NIS library calls since there are no
56functions in the standard C library for reading bootparams. NIS
57support for the hosts, services and rpc databases is enabled by
58uncommenting the
59.Pa nis
60line in
61.Pa /etc/host.conf.
62NIS support for the remaining services is
63activated by adding a special '+' entry to the appropriate file.
64.Pp
65The
66.Nm YP
67subsystem is started automatically in
68.Pa /etc/rc
69if it has been initialized in
70.Pa /etc/sysconfig
71and if the directory
72.Pa /var/yp
73exists (which it does in the default distribution). The default
74NIS domain must also be set with the
75.Xr domainname 1
76command, which will happen automatically at system startup if it is
77specified in
78.Pa /etc/sysconfig.
79.Pp
80NIS is an RPC-based client/server system that allows a group of
81machines within an NIS
82.Em domain
83to share a common set of configuration files. This permits a system
84administrator to set up NIS client systems with only minimal configuration
85data and add, remove or modify configuration data from a single location.
86.Pp
87The canonical copies of all NIS information are stored on a single machine
88called the
89.Pa NIS master server .
90The databases used to store the information are called
91.Pa NIS maps.
92In
93.Tn FreeBSD ,
94these maps are stored in
95.Pa /var/yp/[domainname]
96where
97.Pa [domainname]
98is the name of the NIS domain being served. A single NIS server can
99support several domains at once, therefore it is possible to have several
100such directories, one for each supported domain. Each domain will have
101its own independent set of maps.
102.Pp
103In
104.Tn FreeBSD ,
105the NIS maps are Berkeley DB hashed database files (the
106same format used for the
107.Xr passwd 5
108database files). Other operating systems that support NIS use old-style
109ndbm databases instead (largely because Sun Microsystems originally based
110their NIS implementation on ndbm, and other vendors have simply licensed
111Sun's code rather than design their own implementation with a different
112database format). On these systems, the databases are generally split
113into
114.Em .dir
115and
116.Em .pag
117files which the ndbm code uses to hold separate parts of the hash
118database. The Berkeley DB hash method instead uses a single file for
119both pieces of information. This means that while you may have
120.Pa passwd.byname.dir
121and
122.Pa passwd.byname.pag
123files on other operating systems (both of which are really parts of the
124same map),
125.Tn FreeBSD
126will have only one file called
127.Pa passwd.byname .
128The difference in format is not significant: only the
129NIS server,
130.Xr ypserv 8 ,
131and related tools need to know the database format of the NIS maps. Client
132NIS systems receive all NIS data in ASCII form.
133.Pp
134There are three main types of NIS systems:
135.Bl -enum -offset indent
136.It
137.Pa NIS clients ,
138which query NIS servers for information.
139.It
140.Pa NIS master servers ,
141which maintain the canonical copies of all NIS maps.
142.It
143.Pa NIS slave servers ,
144which maintain backup copies of NIS maps that are periodically
145updated by the master.
146.El
147.Pp
148An NIS client establishes what is called a
149.Em binding
150to a particular NIS server using the
151.Xr ypbind 8
152daemon.
153.Xr Ypbind 8
154checks the system's default domain (as set by the
155.Xr domainname 1
156command) and begins broadcasting RPC requests on the local network.
157These requests specify the name of the domain for which
158.Xr ypbind 8
159is attempting to establish a binding. If a server that has been
160configured to serve the requested domain receives one of the broadcasts,
161it will respond to
162.Xr ypbind 8 ,
163which will record the server's address. If there are several servers
164available (a master and several slaves, for example),
165.Xr ypbind 8
166will use the address of the first one to respond. From that point
167on, the client system will direct all of its NIS requests to that server.
168.Xr Ypbind 8
169will occasionally ``ping'' the server to make sure it's still up
170and running. If it fails to receive a reply to one of its pings
171within a reasonable amount of time,
172.Xr ypbind 8
173will mark the domain as unbound and begin broadcasting again in the
174hopes of locating another server.
175.Pp
176NIS master and slave servers handle all NIS requests with the
177.Xr ypserv 8
178daemon.
179.Xr Ypserv 8
180is responsible for receiving incoming requests from NIS clients,
181translating the requested domain and map name to a path to the
182corresponding database file and transmitting data from the database
183back to the client. There is a specific set of requests that
184.Xr ypserv 8
185is designed to handle, most of which are implemented as functions
186within the standard C library:
187.Bl -bullet -offset indent
188.It
189.Fn yp_order
190-- check the creation date of a particular map
191.It
192.Fn yp_master
193-- obtain the name of the NIS master server for a given
194map/domain
195.It
196.Fn yp_match
197-- lookup the data corresponding to a given in key in a particular
198map/domain
199.It
200.Fn yp_first
201-- obtain the first key/data pair in a particular map/domain
202.It
203.Fn yp_next
204-- pass
205.Xr ypserv 8
206a key in a particular map/domain and have it return the
207key/data pair immediately following it (the functions
208.Fn yp_first
209and
210.Fn yp_next
211can be used to do a sequential search of an NIS map)
212.It
213.Fn yp_all
214-- retrieve the entire contents of a map
215.El
216.Pp
217There are a few other requests which
218.Xr ypserv 8
219is capable of handling (i.e. acknowledge whether or not you can handle
220a particular domain (YPPROC_DOMAIN), or acknowledge only if you can
221handle the domain and be silent otherwise (YPPROC_DOMAIN_NONACK)) but
222these requests are usually generated only by
223.Xr ypbind 8
224and are not meant to be used by standard utilities.
225.Pp
226On networks with a large number of hosts, it is often a good idea to
227use a master server and several slaves rather than just a single master
228server. A slave server provides the exact same information as a master
229server: whenever the maps on the master server are updated, the new
230data should be propagated to the slave systems using the
231.Xr yppush 8
232command. The NIS Makefile
233.Pf ( Pa /var/yp/Makefile )
234will do this automatically if the administrator comments out the
235line which says
236.Em NOPUSH=true
237(NOPUSH is set to true by default because the default configuration is
238for a small network with only one NIS server). The
239.Xr yppush 8
240command will initiate a transaction between the master and slave
241during which the slave will transfer the specified maps from the
242master server using
243.Xr ypxfr 8 .
244(The slave server calls
245.Xr ypxfr 8
246automatically from within
247.Xr ypserv 8 ;
248therefore it is not usually necessary for the administrator
249to use it directly. It can be run manually if
250desired, however.) Maintaining
251slave servers helps improve NIS performance on large
252networks by:
253.Pp
254.Bl -bullet -offset indent
255.It
256Providing backup services in the event that the NIS master crashes
257or becomes unreachable
258.It
259Spreading the client load out over several machines instead of
260causing the master to become overloaded
261.It
262Allowing a single NIS domain to extend beyond
263a local network (the
264.Xr ypbind 8
265daemon might not be able to locate a server automatically if it resides on
266a network outside the reach of its broadcasts. It is possible to force
267.Xr ypbind 8
268to bind to a particular server with
269.Xr ypset 8
270but this is sometimes inconvenient. This problem can be avoided simply by
271placing a slave server on the local network.)
272.El
273.Pp
274The
275.Tn FreeBSD
276.Xr ypserv 8
277is specially designed to provided enhanced security (compared to
278other NIS implementations) when used exclusively with
279.Tn FreeBSD
280client
281systems. The
282.Tn FreeBSD
283password database system (which is derived directly
284from
285.Bx 4.4 )
286includes support for
287.Em "shadow passwords" .
288The standard password database does not contain users' encrypted
289passwords: these are instead stored (along with other information)
290is a separate database which is accessible only by the super-user.
291If the encrypted password database were made available as an NIS
292map, this security feature would be totally disabled, since any user
293is allowed to retrieve NIS data.
294.Pp
295To help prevent this,
296.Tn FreeBSD Ns 's
297NIS server
298handles the shadow password maps
299.Pf ( Pa master.passwd.byname
300and
301.Pa master.passwd.byuid )
302in a special way: the server will only provide access to these
303maps in response to requests that originate on privileged ports.
304Since only the super-user is allowed to bind to a privileged port,
305the server assumes that all such requests come from privileged
306users. All other requests are denied: requests from non-privileged
307ports will receive only an error code from the server. Additionally,
308.Tn FreeBSD Ns 's
309.Xr ypserv 8
310includes support for Wietse Venema's tcp wrapper package; with tcp
311wrapper support enabled, the administrator can configure
312.Xr ypserv 8
313to respond only to selected client machines.
314.Pp
315While these enhancements provide better security than stock NIS,
316they are by no means 100% effective. It is still possible for
317someone with access to your network to spoof the server into disclosing
318the shadow password maps.
319.Pp
320On the client side,
321.Tn FreeBSD Ns 's
322.Fn getpwent 3
323functions will automatically search for the
324.Pa master.passwd
325maps and use them if they exist. If they do, they will be used, and
326all fields in these special maps (class, password age and account
327expiration) will be decoded. If they aren't found, the standard
328.Pa passwd
329maps will be used instead.
330.Sh COMPATIBILITY
331Some systems, such as SunOS 4.x, need NIS to be running in order
332for their hostname resolution functions (
333.Fn gethostbyname ,
334.Fn gethostbyaddr ,
335etc) to work properly. On these systems,
336.Xr ypserv 8
337performs DNS lookups when asked to return information about
338a host that doesn't exist in its
339.Pa hosts.byname
340or
341.Pa hosts.byaddr
342maps.
343.Tn FreeBSD Ns 's
344resolver uses DNS by default (it can be made to use
345NIS, if desired), therefore its NIS server doesn't do DNS lookups
346by default. However,
347.Xr ypserv 8
348can be made to perform DNS lookups if it is started with a special
349flag. It can also be made to register itself as an NIS v1 server
350in order to placate certain systems that insist on the presence of
351a v1 server
352.Pf ( Tn FreeBSD
353uses only NIS v2, but many other systems,
354including
355.Tn SunOS
3564.x, search for both a v1 and v2 server when binding).
357.Tn FreeBSD Ns 's
358.Xr ypserv 8
359does not actually handle NIS v1 requests, but this ``kludge mode''
360is useful for silencing stubborn systems that search for both
361a v1 and v2 server.
362.Pp
363(Please see the
364.Xr ypserv 8
365manual page for a detailed description of these special features
366and flags.)
367.Sh BUGS
368While
369.Tn FreeBSD
370now has both NIS client and server capabilities,
371it does not yet have support for
372.Xr ypupdated 8
373or the
374.Fn yp_update
375function. Both of these require secure RPC, which
376.Tn FreeBSD
377doesn't
378support yet either.
379.Pp
380The
381.Xr getservent 3
382and
383.Xr getprotoent 3
384functions do not yet have NIS support. Fortunately, these files
385don't need to be updated that often.
386.Pp
387Many more manual pages should be written, especially
388.Xr ypclnt 3 .
389For the time being, seek out a local Sun machine and read the
390manuals for there.
391.Pp
392Neither Sun nor this author have found a clean way to handle
393the problems that occur when ypbind cannot find its server
394upon bootup.
395.Sh HISTORY
396The
397.Nm YP
398subsystem was written from the ground up by Theo de Raadt
399to be compatible to Sun's implementation. Bug fixes, improvements
400and NIS server support were later added by Bill Paul. The server-side
401code was originally written by Peter Eriksson and Tobias Reber and
402is subject to the GNU Public License. No Sun code was
403referenced.
404