xref: /freebsd/share/man/man8/yp.8 (revision a8445737e740901f5f2c8d24c12ef7fc8b00134e)
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.13 1997/10/31 12:30:49 charnier 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
56.Tn NIS
57library calls since there are no
58functions in the standard C library for reading bootparams.
59.Tn NIS
60support for the hosts, services and rpc databases is enabled by
61uncommenting the
62.Em nis
63line in
64.Pa /etc/host.conf .
65.Tn NIS
66support for the remaining services is
67activated by adding a special '+' entry to the appropriate file.
68.Pp
69The
70.Nm YP
71subsystem is started automatically in
72.Pa /etc/rc
73if it has been initialized in
74.Pa /etc/rc.conf
75and if the directory
76.Pa /var/yp
77exists (which it does in the default distribution). The default
78.Tn NIS
79domain must also be set with the
80.Xr domainname 1
81command, which will happen automatically at system startup if it is
82specified in
83.Pa /etc/rc.conf .
84.Pp
85.Tn NIS
86is an
87.Tn RPC Ns -based
88client/server system that allows a group of
89machines within an
90.Tn NIS
91domain to share a common set of configuration files. This permits a system
92administrator to set up
93.Tn NIS
94client systems with only minimal configuration
95data and add, remove or modify configuration data from a single location.
96.Pp
97The canonical copies of all
98.Tn NIS
99information are stored on a single machine
100called the
101.Em Tn NIS master server .
102The databases used to store the information are called
103.Em Tn NIS maps .
104In
105.Bx Free ,
106these maps are stored in
107.Pa /var/yp/[domainname]
108where
109.Pa [domainname]
110is the name of the
111.Tn NIS
112domain being served. A single
113.Tn NIS
114server can
115support several domains at once, therefore it is possible to have several
116such directories, one for each supported domain. Each domain will have
117its own independent set of maps.
118.Pp
119In
120.Bx Free ,
121the
122.Tn NIS
123maps are Berkeley DB hashed database files (the
124same format used for the
125.Xr passwd 5
126database files). Other operating systems that support
127.Tn NIS
128use old-style
129ndbm databases instead (largely because Sun Microsystems originally based
130their
131.Tn NIS
132implementation on ndbm, and other vendors have simply licensed
133Sun's code rather than design their own implementation with a different
134database format). On these systems, the databases are generally split
135into
136.Em .dir
137and
138.Em .pag
139files which the ndbm code uses to hold separate parts of the hash
140database. The Berkeley DB hash method instead uses a single file for
141both pieces of information. This means that while you may have
142.Pa passwd.byname.dir
143and
144.Pa passwd.byname.pag
145files on other operating systems (both of which are really parts of the
146same map),
147.Bx Free
148will have only one file called
149.Pa passwd.byname .
150The difference in format is not significant: only the
151.Tn NIS
152server,
153.Xr ypserv 8 ,
154and related tools need to know the database format of the
155.Tn NIS
156maps. Client
157.Tn NIS
158systems receive all
159.Tn NIS
160data in
161.Tn ASCII
162form.
163.Pp
164There are three main types of
165.Tn NIS
166systems:
167.Bl -enum -offset indent
168.It
169.Pa Tn NIS clients ,
170which query
171.Tn NIS
172servers for information.
173.It
174.Pa Tn NIS master servers ,
175which maintain the canonical copies of all
176.Tn NIS
177maps.
178.It
179.Pa Tn NIS slave servers ,
180which maintain backup copies of
181.Tn NIS
182maps that are periodically
183updated by the master.
184.El
185.Pp
186An
187.Tn NIS
188client establishes what is called a
189.Em binding
190to a particular
191.Tn NIS
192server using the
193.Xr ypbind 8
194daemon.
195.Xr Ypbind 8
196checks the system's default domain (as set by the
197.Xr domainname 1
198command) and begins broadcasting
199.Tn RPC
200requests on the local network.
201These requests specify the name of the domain for which
202.Xr ypbind 8
203is attempting to establish a binding. If a server that has been
204configured to serve the requested domain receives one of the broadcasts,
205it will respond to
206.Xr ypbind 8 ,
207which will record the server's address. If there are several servers
208available (a master and several slaves, for example),
209.Xr ypbind 8
210will use the address of the first one to respond. From that point
211on, the client system will direct all of its
212.Tn NIS
213requests to that server.
214.Xr Ypbind 8
215will occasionally ``ping'' the server to make sure it's still up
216and running. If it fails to receive a reply to one of its pings
217within a reasonable amount of time,
218.Xr ypbind 8
219will mark the domain as unbound and begin broadcasting again in the
220hopes of locating another server.
221.Pp
222.Tn NIS
223master and slave servers handle all
224.Tn NIS
225requests with the
226.Xr ypserv 8
227daemon.
228.Xr Ypserv 8
229is responsible for receiving incoming requests from
230.Tn NIS
231clients,
232translating the requested domain and map name to a path to the
233corresponding database file and transmitting data from the database
234back to the client. There is a specific set of requests that
235.Xr ypserv 8
236is designed to handle, most of which are implemented as functions
237within the standard C library:
238.Bl -bullet -offset indent
239.It
240.Fn yp_order
241-- check the creation date of a particular map
242.It
243.Fn yp_master
244-- obtain the name of the
245.Tn NIS
246master server for a given
247map/domain
248.It
249.Fn yp_match
250-- lookup the data corresponding to a given in key in a particular
251map/domain
252.It
253.Fn yp_first
254-- obtain the first key/data pair in a particular map/domain
255.It
256.Fn yp_next
257-- pass
258.Xr ypserv 8
259a key in a particular map/domain and have it return the
260key/data pair immediately following it (the functions
261.Fn yp_first
262and
263.Fn yp_next
264can be used to do a sequential search of an
265.Tn NIS
266map)
267.It
268.Fn yp_all
269-- retrieve the entire contents of a map
270.El
271.Pp
272There are a few other requests which
273.Xr ypserv 8
274is capable of handling (i.e. acknowledge whether or not you can handle
275a particular domain (YPPROC_DOMAIN), or acknowledge only if you can
276handle the domain and be silent otherwise (YPPROC_DOMAIN_NONACK)) but
277these requests are usually generated only by
278.Xr ypbind 8
279and are not meant to be used by standard utilities.
280.Pp
281On networks with a large number of hosts, it is often a good idea to
282use a master server and several slaves rather than just a single master
283server. A slave server provides the exact same information as a master
284server: whenever the maps on the master server are updated, the new
285data should be propagated to the slave systems using the
286.Xr yppush 8
287command. The
288.Tn NIS
289Makefile
290.Pf ( Pa /var/yp/Makefile )
291will do this automatically if the administrator comments out the
292line which says
293.Em NOPUSH=true
294(NOPUSH is set to true by default because the default configuration is
295for a small network with only one
296.Tn NIS
297server). The
298.Xr yppush 8
299command will initiate a transaction between the master and slave
300during which the slave will transfer the specified maps from the
301master server using
302.Xr ypxfr 8 .
303(The slave server calls
304.Xr ypxfr 8
305automatically from within
306.Xr ypserv 8 ;
307therefore it is not usually necessary for the administrator
308to use it directly. It can be run manually if
309desired, however.) Maintaining
310slave servers helps improve
311.Tn NIS
312performance on large
313networks by:
314.Pp
315.Bl -bullet -offset indent
316.It
317Providing backup services in the event that the
318.Tn NIS
319master crashes
320or becomes unreachable
321.It
322Spreading the client load out over several machines instead of
323causing the master to become overloaded
324.It
325Allowing a single
326.Tn NIS
327domain to extend beyond
328a local network (the
329.Xr ypbind 8
330daemon might not be able to locate a server automatically if it resides on
331a network outside the reach of its broadcasts. It is possible to force
332.Xr ypbind 8
333to bind to a particular server with
334.Xr ypset 8
335but this is sometimes inconvenient. This problem can be avoided simply by
336placing a slave server on the local network.)
337.El
338.Pp
339The
340.Bx Free
341.Xr ypserv 8
342is specially designed to provided enhanced security (compared to
343other
344.Tn NIS
345implementations) when used exclusively with
346.Bx Free
347client
348systems. The
349.Bx Free
350password database system (which is derived directly
351from
352.Bx 4.4 )
353includes support for
354.Em "shadow passwords" .
355The standard password database does not contain users' encrypted
356passwords: these are instead stored (along with other information)
357is a separate database which is accessible only by the super-user.
358If the encrypted password database were made available as an
359.Tn NIS
360map, this security feature would be totally disabled, since any user
361is allowed to retrieve
362.Tn NIS
363data.
364.Pp
365To help prevent this,
366.Bx Free Ns 's
367.Tn NIS
368server handles the shadow password maps
369.Pf ( Pa master.passwd.byname
370and
371.Pa master.passwd.byuid )
372in a special way: the server will only provide access to these
373maps in response to requests that originate on privileged ports.
374Since only the super-user is allowed to bind to a privileged port,
375the server assumes that all such requests come from privileged
376users. All other requests are denied: requests from non-privileged
377ports will receive only an error code from the server. Additionally,
378.Bx Free Ns 's
379.Xr ypserv 8
380includes support for Wietse Venema's tcp wrapper package; with tcp
381wrapper support enabled, the administrator can configure
382.Xr ypserv 8
383to respond only to selected client machines.
384.Pp
385While these enhancements provide better security than stock
386.Tn NIS Ns ,
387they are by no means 100% effective. It is still possible for
388someone with access to your network to spoof the server into disclosing
389the shadow password maps.
390.Pp
391On the client side,
392.Bx Free Ns 's
393.Fn getpwent 3
394functions will automatically search for the
395.Pa master.passwd
396maps and use them if they exist. If they do, they will be used, and
397all fields in these special maps (class, password age and account
398expiration) will be decoded. If they aren't found, the standard
399.Pa passwd
400maps will be used instead.
401.Sh COMPATIBILITY
402Some systems, such as SunOS 4.x, need
403.Tn NIS
404to be running in order
405for their hostname resolution functions (
406.Fn gethostbyname ,
407.Fn gethostbyaddr ,
408etc) to work properly. On these systems,
409.Xr ypserv 8
410performs
411.Tn DNS
412lookups when asked to return information about
413a host that doesn't exist in its
414.Pa hosts.byname
415or
416.Pa hosts.byaddr
417maps.
418.Bx Free Ns 's
419resolver uses
420.Tn DNS
421by default (it can be made to use
422.Tn NIS Ns ,
423if desired), therefore its
424.Tn NIS
425server doesn't do
426Tn DNS
427lookups
428by default. However,
429.Xr ypserv 8
430can be made to perform
431.Tn DNS
432lookups if it is started with a special
433flag. It can also be made to register itself as an
434.Tn NIS
435v1 server
436in order to placate certain systems that insist on the presence of
437a v1 server
438.Pf ( Bx Free
439uses only
440.Tn NIS
441v2, but many other systems,
442including
443.Tn SunOS
4444.x, search for both a v1 and v2 server when binding).
445.Bx Free Ns 's
446.Xr ypserv 8
447does not actually handle
448.Tn NIS
449v1 requests, but this ``kludge mode''
450is useful for silencing stubborn systems that search for both
451a v1 and v2 server.
452.Pp
453(Please see the
454.Xr ypserv 8
455manual page for a detailed description of these special features
456and flags.)
457.Sh BUGS
458While
459.Bx Free
460now has both
461.Tn NIS
462client and server capabilities, it does not yet have support for
463.Xr ypupdated 8
464or the
465.Fn yp_update
466function. Both of these require secure
467.Tn RPC Ns ,
468which
469.Bx Free
470doesn't
471support yet either.
472.Pp
473The
474.Xr getservent 3
475and
476.Xr getprotoent 3
477functions do not yet have
478.Tn NIS
479support. Fortunately, these files
480don't need to be updated that often.
481.Pp
482Many more manual pages should be written, especially
483.Xr ypclnt 3 .
484For the time being, seek out a local Sun machine and read the
485manuals for there.
486.Pp
487Neither Sun nor this author have found a clean way to handle
488the problems that occur when ypbind cannot find its server
489upon bootup.
490.Sh HISTORY
491The
492.Nm YP
493subsystem was written from the ground up by
494.An Theo de Raadt
495to be compatible to Sun's implementation. Bug fixes, improvements
496and
497.Tn NIS
498server support were later added by
499.An Bill Paul Ns .
500The server-side code was originally written by
501.An Peter Eriksson
502and
503.An Tobias Reber
504and is subject to the GNU Public License. No Sun code was
505referenced.
506