xref: /freebsd/usr.sbin/ypserv/ypserv.8 (revision 4cf49a43559ed9fdad601bdcccd2c55963008675)
1.\" Copyright (c) 1995
2.\"	Bill Paul <wpaul@ctr.columbia.edu>.  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. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by Bill Paul.
15.\" 4. Neither the name of the author nor the names of any co-contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\" $FreeBSD$
32.\"
33.Dd February 4, 1995
34.Dt YPSERV 8
35.Os
36.Sh NAME
37.Nm ypserv
38.Nd NIS database server
39.Sh SYNOPSIS
40.Nm
41.Op Fl n
42.Op Fl d
43.Op Fl p Ar path
44.Sh DESCRIPTION
45.Tn NIS
46is an RPC-based service designed to allow a number of UNIX-based
47machines to share a common set of configuration files. Rather than
48requiring a system administrator to update several copies of files
49such as
50.Pa /etc/hosts ,
51.Pa /etc/passwd
52and
53.Pa /etc/group ,
54which tend to require frequent changes in most environments,
55.Tn NIS
56allows groups of computers to share one set of data which can be
57updated from a single location.
58.Pp
59The
60.Nm
61program is the server that distributes
62.Tn NIS
63databases to client systems within an
64.Tn NIS
65.Em domain .
66Each client in an
67.Tn NIS
68domain must have its domainname set to
69one of the domains served by
70.Nm
71using the
72.Xr domainname 1
73command. The clients must also run
74.Xr ypbind 8
75in order to attach to a particular server, since it is possible to
76have several servers within a single
77.Tn NIS
78domain.
79.Pp
80The databases distributed by
81.Nm
82are stored in
83.Pa /var/yp/[domainname]
84where
85.Pa domainname
86is the name of the domain being served. There can be several
87such directories with different domainnames, and you need only one
88.Nm
89daemon to handle them all.
90.Pp
91The databases, or
92.Pa maps
93as they are often called,
94are created by
95.Pa /var/yp/Makefile
96using several system files as source. The database files are in
97.Xr db 3
98format to help speed retrieval when there are many records involved.
99In
100.Bx Free ,
101the maps are always readable and writable only by root for security
102reasons. Technically this is only necessary for the password
103maps, but since the data in the other maps can be found in
104other world-readable files anyway, it doesn't hurt and it's considered
105good general practice.
106.Pp
107The
108.Nm
109program is started by
110.Pa /etc/rc.network
111if it has been enabled in
112.Pa /etc/rc.conf .
113.Sh SPECIAL FEATURES
114There are some problems associated with distributing FreeBSD's password
115database via
116.Tn NIS Ns :
117.Bx Free
118normally only stores encrypted passwords
119in
120.Pa /etc/master.passwd ,
121which is readable and writable only by root. By turning this file
122into an
123.Tn NIS
124map, this security feature would be completely defeated.
125.Pp
126To make up for this, the
127.Bx Free
128version of
129.Nm
130handles the
131.Pa master.passwd.byname
132and
133.Pa master.basswd.byuid
134maps in a special way. When the server receives a request to access
135either of these two maps, it will check the TCP port from which the
136request originated and return an error if the port number is greater
137than 1023. Since only the superuser is allowed to bind to TCP ports
138with values less than 1024, the server can use this test to determine
139whether or not the access request came from a privileged user.
140Any requests made by non-privileged users are therefore rejected.
141.Pp
142Furthermore, the
143.Xr getpwent 3
144routines in
145.Bx Free Ns 's
146standard C library will only attempt to retrieve
147data from the
148.Pa master.passwd.byname
149and
150.Pa master.passwd.byuid
151maps for the superuser: if a normal user calls any of these functions,
152the standard
153.Pa passwd.byname
154and
155.Pa passwd.byuid
156maps will be accessed instead. The latter two maps are constructed by
157.Pa /var/yp/Makefile
158by parsing the
159.Pa master.passwd
160file and stripping out the password fields, and are therefore
161safe to pass on to unprivileged users. In this way, the shadow password
162aspect of the protected
163.Pa master.passwd
164database is maintained through
165.Tn NIS .
166.Pp
167.Sh NOTES
168.Ss Setting Up Master and Slave Servers
169.Xr ypinit 8
170is a convenient script that will help setup master and slave
171.Tn NIS
172servers.
173.Ss Limitations
174There are two problems inherent with password shadowing in
175.Tn NIS
176that users should
177be aware of:
178.Bl -enum -offset indent
179.It
180The
181.Sq TCP port less than 1024
182test is trivial to defeat for users with
183unrestricted access to machines on your network (even those machines
184which do not run UNIX-based operating systems).
185.It
186If you plan to use a
187.Bx Free
188system to serve
189.Bx non-Free
190clients that
191have no support for password shadowing (which is most of them), you
192will have to disable the password shadowing entirely by uncommenting the
193.Em UNSECURE=True
194entry in
195.Pa /var/yp/Makefile .
196This will cause the standard
197.Pa passwd.byname
198and
199.Pa passwd.byuid
200maps to be generated with valid encrypted password fields, which is
201necessary in order for
202.Bx non-Free
203clients to perform user
204authentication through
205.Tn NIS .
206.El
207.Pp
208.Ss Security
209In general, any remote user can issue an RPC to
210.Nm
211and retrieve the contents of your
212.Tn NIS
213maps, provided the remote user
214knows your domain name. To prevent such unauthorized transactions,
215.Nm
216supports a feature called
217.Pa securenets
218which can be used to restrict access to a given set of hosts.
219At startup,
220.Nm
221will attempt to load the securenets information from a file
222called
223.Pa /var/yp/securenets .
224(Note that this path varies depending on the path specified with
225the
226.Fl p
227option, which is explained below.) This file contains entries
228that consist of a network specification and a network mask separated
229by white space.
230Lines starting with
231.Dq \&#
232are considered to be comments. A
233sample securenets file might look like this:
234.Bd -unfilled -offset indent
235# allow connections from local host -- mandatory
236127.0.0.1     255.255.255.255
237# allow connections from any host
238# on the 192.168.128.0 network
239192.168.128.0 255.255.255.0
240# allow connections from any host
241# between 10.0.0.0 to 10.0.15.255
24210.0.0.0      255.255.240.0
243.Ed
244.Pp
245If
246.Nm
247receives a request from an address that matches one of these rules,
248it will process the request normally. If the address fails to match
249a rule, the request will be ignored and a warning message will be
250logged. If the
251.Pa /var/yp/securenets
252file does not exist,
253.Nm
254will allow connections from any host.
255.Pp
256The
257.Nm
258program also has support for Wietse Venema's
259.Em tcpwrapper
260package, though it is not compiled in by default since
261the
262.Em tcpwrapper
263package is not distributed with
264.Bx Free .
265However, if you have
266.Pa libwrap.a
267and
268.Pa tcpd.h ,
269you can easily recompile
270.Nm
271with them. This allows the administrator to use the tcpwrapper
272configuration files (
273.Pa /etc/hosts.allow
274and
275.Pa /etc/hosts.deny )
276for access control instead of
277.Pa /var/yp/securenets .
278.Pp
279Note: while both of these access control mechanisms provide some
280security, they, like the privileged port test, are both vulnerable
281to
282.Dq IP spoofing
283attacks.
284.Pp
285.Ss NIS v1 compatibility
286This version of
287.Nm
288has some support for serving
289.Tn NIS
290v1 clients.
291.Bx Free Ns 's
292.Tn NIS
293implementation only uses the
294.Tn NIS
295v2 protocol, however other implementations
296include support for the v1 protocol for backwards compatibility
297with older systems. The
298.Xr ypbind 8
299daemons supplied with these systems will try to establish a binding
300to an
301.Tn NIS
302v1 server even though they may never actually need it (and they may
303persist in broadcasting in search of one even after they receive a
304response from a v2 server). Note that while
305support for normal client calls is provided, this version of
306.Nm
307does not handle v1 map transfer requests; consequently, it can not
308be used as a master or slave in conjunction with older
309.Tn NIS
310servers that
311only support the v1 protocol. Fortunately, there probably aren't any
312such servers still in use today.
313.Ss NIS servers that are also NIS clients
314Care must be taken when running
315.Nm
316in a multi-server domain where the server machines are also
317.Tn NIS
318clients. It is generally a good idea to force the servers to
319bind to themselves rather than allowing them to broadcast bind
320requests and possibly become bound to each other: strange failure
321modes can result if one server goes down and
322others are dependent upon on it. (Eventually all the clients will
323time out and attempt to bind to other servers, but the delay
324involved can be considerable and the failure mode is still present
325since the servers might bind to each other all over again).
326.Pp
327Refer to the
328.Xr ypbind 8
329man page for details on how to force it to bind to a particular
330server.
331.Sh OPTIONS
332The following options are supported by
333.Nm Ns :
334.Bl -tag -width flag
335.It Fl n
336This option affects the way
337.Nm
338handles yp_match requests for the
339.Pa hosts.byname
340and
341.Pa hosts.byaddress
342maps. By default, if
343.Nm
344can't find an entry for a given host in its hosts maps, it will
345return an error and perform no further processing. With the
346.Fl n
347flag,
348.Nm
349will go one step further: rather than giving up immediately, it
350will try to resolve the hostname or address using a DNS nameserver
351query. If the query is successful,
352.Nm
353will construct a fake database record and return it to the client,
354thereby making it seem as though the client's yp_match request
355succeeded.
356.Pp
357This feature is provided for compatiblity with SunOS 4.1.x,
358which has brain-damaged resolver functions in its standard C
359library that depend on
360.Tn NIS
361for hostname and address resolution.
362.Bx Free Ns 's
363resolver can be configured to do DNS
364queries directly, therefore it is not necessary to enable this
365option when serving only
366.Bx Free
367.Tn NIS
368clients.
369.It Fl d
370Cause the server to run in debugging mode. Normally,
371.Nm
372reports only unusual errors (access violations, file access failures)
373using the
374.Xr syslog 3
375facility. In debug mode, the server does not background
376itself and prints extra status messages to stderr for each
377request that it receives. Also, while running in debug mode,
378.Nm
379will not spawn any additional subprocesses as it normally does
380when handling yp_all requests or doing DNS lookups. (These actions
381often take a fair amount of time to complete and are therefore handled
382in subprocesses, allowing the parent server process to go on handling
383other requests.) This makes it easier to trace the server with
384a debugging tool.
385.It Fl p Ar path
386Normally,
387.Nm
388assumes that all
389.Tn NIS
390maps are stored under
391.Pa /var/yp .
392The
393.Fl p
394flag may be used to specify an alternate
395.Tn NIS
396root path, allowing
397the system administrator to move the map files to a different place
398within the filesystem.
399.El
400.Sh FILES
401.Bl -tag -width Pa -compact
402.It Pa /var/yp/[domainname]/[maps]
403the
404.Tn NIS
405maps
406.It Pa /etc/host.conf
407resolver configuration file
408.It Pa /var/yp/securenets
409host access control file
410.El
411.Sh SEE ALSO
412.Xr ypcat 1 ,
413.Xr db 3 ,
414.Xr yp 4 ,
415.Xr rpc.yppasswdd 8 ,
416.Xr ypbind 8 ,
417.Xr ypinit 8 ,
418.Xr yppush 8 ,
419.Xr ypxfr 8
420.Sh AUTHORS
421.An Bill Paul Aq wpaul@ctr.columbia.edu
422.Sh HISTORY
423This version of
424.Nm
425first appeared in
426.Fx 2.2 .
427