xref: /freebsd/share/man/man8/yp.8 (revision 953a3198a35204535cc9d450f04da982a4fea59b)
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.3 1995/03/23 06:05:04 jkh 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.Nm bootparamd
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.Nm /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.Nm 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 FreeBSD, these maps are stored in
93.Pa /var/yp/[domainname]
94where
95.Pa [domainname]
96is the name of the NIS domain being served. A single NIS server can
97support several domains at once, therefore it is possible to have several
98such directories, one for each supported domain. Each domain will have
99its own independent set of maps.
100.Pp
101In FreeBSD, the NIS maps are Berkeley DB hashed database files (the
102same format used for the
103.Xr passwd 5
104database files). Other operating systems that support NIS use old-style
105ndbm databases instead (largely because Sun Microsystems originally based
106their NIS implementation on ndbm, and other vendors have simply licensed
107Sun's code rather than design their own implementation with a different
108database format). On these systems, the databases are generally split
109into
110.Nm .dir
111and
112.Nm .pag
113files which the ndbm code uses to hold seperate parts of the hash
114database. The Berkeley DB hash method instead uses a single file for
115both pieces of information. This means that while you may have
116.Pa passwd.byname.dir
117and
118.Pa passwd.byname.pag
119files on other operating systems (both of which are really parts of the
120same map), FreeBSD will have only one file called
121.Pa passwd.byname .
122The difference in format is not significant: only the
123NIS server,
124.Xr ypserv 8 ,
125and related tools need to know the database format of the NIS maps. Client
126NIS systems receive all NIS data in ASCII form.
127.Pp
128There are three main types of NIS systems:
129.Bl -enum -offset indent
130.It
131.Pa NIS clients ,
132which query NIS servers for information.
133.It
134.Pa NIS master servers ,
135which maintain the canonical copies of all NIS maps.
136.It
137.Pa NIS slave servers ,
138which maintain backup copies of NIS maps that are periodically
139updated by the master.
140.El
141.Pp
142An NIS client establishes what is called a
143.Nm binding
144to a particular NIS server using the
145.Xr ypbind 8
146daemon.
147.Xr Ypbind 8
148checks the system's default domain (as set by the
149.Xr domainname 1
150command) and begins broadcasting RPC requests on the local network.
151These requests specify the name of the domain for which
152.Xr ypbind 8
153is attempting to establish a binding. If a server that has been
154configured to serve the requested domain receives one of the broadcasts,
155it will respond to
156.Xr ypbind 8 ,
157which will record the server's address. If there are several servers
158available (a master and several slaves, for example),
159.Xr ypbind 8
160will use the address of the first one to respond. From that point
161on, the client system will direct all of its NIS requests to that server.
162.Xr Ypbind 8
163will occasionally ``ping'' the server to make sure it's still up
164and running. If it fails to receive a reply to one of its pings
165withing a reasonable amount of time,
166.Xr ypbind 8
167will mark the domain as unbound and begin broadcasting again in the
168hopes of locating another server.
169.Pp
170NIS master and slave servers handle all NIS requests with the
171.Xr ypserv 8
172daemon.
173.Xr Ypserv 8
174is responsible for receiving incoming requests from NIS clients,
175translating the requested domain and map name to a path to the
176corresponding database file and transmitting data from the database
177back to the client. There is a specific set of requests that
178.Xr ypserv 8
179is designed to handle, most of which are implemented as functions
180within the standard C library:
181.Bl -bullet -offset indent
182.It
183.Nm yp_order()
184-- check the creation date of a particular map
185.It
186.Nm yp_master()
187-- obtain the name of the NIS master server for a given
188map/domain
189.It
190.Nm yp_match()
191-- lookup the data corresponding to a given in key in a particular
192map/domain
193.It
194.Nm yp_first()
195-- obtain the first key/data pair in a particular map/domain
196.It
197.Nm yp_next()
198-- pass
199.Xr ypserv 8
200a key in a particular map/domain and have it return the
201key/data pair immediately following it (yp_first() and yp_next()
202can be used to do a sequential search of an NIS map)
203.It
204.Nm yp_all()
205-- retreive the entire contents of a map
206.El
207.Pp
208There are a few other requests which
209.Xr ypserv
210is capable of handling (i.e. acknowledge whether or not you can handle
211a particular domain (YPPROC_DOMAIN), or acknowledge only if you can
212handle the domain and be silent otherwise (YPPROC_DOMAIN_NONACK)) but
213these requests are usually generated only by
214.Xr ypbind
215and are not meant to be used by standard utilities.
216.Pp
217On networks with a large number of hosts, it is often a good idea to
218use a master server and several slaves rather than just a single master
219server. A slave server provides the exact same information as a master
220server: whenever the maps on the master server are updated, the new
221data should be propagated to the slave systems using the
222.Xr yppush 8
223command. The NIS Makefile (
224.Pa /var/yp/Makefile )
225will do this automatically if the administrator comments out the
226line which says
227.Nm NOPUSH=true
228(NOPUSH is set to true by default because the default configuration is
229for a small network with only one NIS server). The
230.Xr yppush 8
231command will initiate a transaction between the master and slave
232during which the slave will transfer the specified maps from the
233master server using
234.Xr ypxfr 8 .
235(The slave server calls
236.Xr ypxfr 8
237automatically from within
238.Xr ypserv 8 ;
239therefore it is not usually necessary for the administrator
240to use it directly. It can be run manually if
241desired, however.) Maintaining
242slave servers helps improve NIS performance on large
243networks by:
244.Pp
245.Bl -bullet -offset indent
246.It
247Providing backup services in the event that the NIS master crashes
248or becomes unreachanble
249.It
250Spreading the client load out over several machines instead of
251causing the master to become overloaded
252.It
253Allowing a single NIS domain to extend beyond
254a local network (the
255.Xr ypbind 8
256daemon might not be able to locate a server automatically if it resides on
257a network outside the reach of its broadcasts. It is possible to force
258.Xr ypbind 8
259to bind to a particular server with
260.Xr ypset 8
261but this is sometimes inconvenient. This problem can be avoided simply by
262placing a slave server on the local network.)
263.El
264.Pp
265The FreeBSD
266.Xr ypserv 8
267is specially designed to provided enhanced security (compared to
268other NIS implementations) when used exclusively with FreeBSD client
269systems. The FreeBSD password database system (which is derived directly
270form 4.4BSD) includes support for
271.Nm shadow passwords .
272The standard password database does not contain users' encrpyted
273passwords: these are instead stored (along with other information)
274is a seperate database which is accesible only by the super-user.
275If the encrypted password database were made available as an NIS
276map, this security feature would be totally disabled, since any user
277is allowed to retrieve NIS data.
278.Pp
279To help prevent this, FreeBSD's NIS server
280handles the shadow password maps (
281.Pa master.passwd.byname
282and
283.Pa master.passwd.byuid )
284in a special way: the server will only provide access to these
285maps in response to requests that originate on privileged ports.
286Since only the super-user is allowed to bind to a privileged port,
287the server assumes that all such requests come from privileged
288users. All other requests are denied: requests from non-privileged
289ports will receive only an error code from the server. Additionally,
290FreeBSD's
291.Xr ypserv 8
292includes support for Wietse Venema's tcp wrapper package; with tcp
293wrapper support enabled, the administrator can configure
294.Xr ypserv 8
295to respond only to selected client machines.
296.Pp
297While these enhancements provide better security than stock NIS,
298they are by no means 100% effective. It is still possible for
299someone with access to your network to spoof the server into disclosing
300the shadow password maps.
301.Pp
302On the client side, FreeBSD's
303.Fn getpwent 3
304functions will automatically search for the
305.Pa master.passwd
306maps and use them if they exist. If they do, they will be used, and
307all fields in these special maps (class, password age and account
308expiration) will be decoded. If they aren't found, the standard
309.Pa passwd
310maps will be used instead.
311.Sh COMPATIBILITY
312Some systems, such as SunOS 4.x, need NIS to be running in order
313for their hostname resolution functions (
314.Fn gethostbyname ,
315.Fn gethostbyaddr ,
316etc) to work properly. On these systems,
317.Xr ypserv 8
318performs DNS lookups when asked to return information about
319a host that doesn't exist in its
320.Pa hosts.byname
321or
322.Pa hosts.byaddr
323maps. FreeBSD's resolver uses DNS by default (it can be made to use
324NIS, if desired), therefore its NIS server doesn't do DNS lookups
325by default. However,
326.Xr ypserv 8
327can be made to perform DNS lookups if it is started with a special
328flag. It can also be made to register itself as an NIS v1 server
329in order to placate certain systems that insist on the presence of
330a v1 server (FreeBSD uses only NIS v2, but many other systems,
331including SunOS 4.x, search for both a v1 and v2 server when binding).
332FreeBSD's
333.Xr ypserv 8
334does not actually handle NIS v1 requests, but this ``kludge mode''
335is useful for silencing stubborn systems that search for both
336a v1 and v2 server.
337.Pp
338(Please see the
339.Xr ypserv 8
340manual page for a detailed description of these special features
341and flags.)
342.Sh BUGS
343While FreeBSD now has both NIS client and server capabilities,
344it does not yet have support for
345.Nm ypupdated
346or the
347.Fn yp_update
348function. Both of these require secure RPC, which FreeBSD doesn't
349support yet either.
350.Pp
351The
352.Xr getservent 3
353and
354.Xr getprotoent 3
355functions do not yet have NIS support. Fortunately, these files
356don't need to be updated that often.
357.Pp
358Many more manual pages should be written, especially ypclnt(3).
359For the time being, seek out a local Sun machine and read the
360manuals for there.
361.Pp
362FreeBSD's server-side support is based on GPL'ed code originally
363written for Linux. It really needs its own implementation that is not
364subject to the GPL.
365.Pp
366Neither Sun nor this author have found a clean way to handle
367the problems that occur when ypbind cannot find its server
368upon bootup.
369.Sh HISTORY
370The
371.Nm YP
372subsystem was written from the ground up by Theo de Raadt
373to be compatible to Sun's implimentation. Bug fixes, improvements
374and NIS server support were later added by Bill Paul. The server-side
375code was originally written by Peter Eriksson and Tobias Reber and
376is subject to the GNU Public License. No Sun code was
377referenced.
378