xref: /freebsd/usr.sbin/ypserv/ypserv.8 (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
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.Fx ,
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 a
115.Fx
116password
117database via
118.Tn NIS Ns :
119.Fx
120normally only stores encrypted passwords
121in
122.Pa /etc/master.passwd ,
123which is readable and writable only by root. By turning this file
124into an
125.Tn NIS
126map, this security feature would be completely defeated.
127.Pp
128To make up for this, the
129.Fx
130version of
131.Nm
132handles the
133.Pa master.passwd.byname
134and
135.Pa master.basswd.byuid
136maps in a special way. When the server receives a request to access
137either of these two maps, it will check the TCP port from which the
138request originated and return an error if the port number is greater
139than 1023. Since only the superuser is allowed to bind to TCP ports
140with values less than 1024, the server can use this test to determine
141whether or not the access request came from a privileged user.
142Any requests made by non-privileged users are therefore rejected.
143.Pp
144Furthermore, the
145.Xr getpwent 3
146routines in the
147.Fx
148standard C library will only attempt to retrieve
149data from the
150.Pa master.passwd.byname
151and
152.Pa master.passwd.byuid
153maps for the superuser: if a normal user calls any of these functions,
154the standard
155.Pa passwd.byname
156and
157.Pa passwd.byuid
158maps will be accessed instead. The latter two maps are constructed by
159.Pa /var/yp/Makefile
160by parsing the
161.Pa master.passwd
162file and stripping out the password fields, and are therefore
163safe to pass on to unprivileged users. In this way, the shadow password
164aspect of the protected
165.Pa master.passwd
166database is maintained through
167.Tn NIS .
168.Pp
169.Sh NOTES
170.Ss Setting Up Master and Slave Servers
171.Xr ypinit 8
172is a convenient script that will help setup master and slave
173.Tn NIS
174servers.
175.Ss Limitations
176There are two problems inherent with password shadowing in
177.Tn NIS
178that users should
179be aware of:
180.Bl -enum -offset indent
181.It
182The
183.Sq TCP port less than 1024
184test is trivial to defeat for users with
185unrestricted access to machines on your network (even those machines
186which do not run UNIX-based operating systems).
187.It
188If you plan to use a
189.Fx
190system to serve
191.No non- Ns Tn FreeBSD
192clients that
193have no support for password shadowing (which is most of them), you
194will have to disable the password shadowing entirely by uncommenting the
195.Em UNSECURE=True
196entry in
197.Pa /var/yp/Makefile .
198This will cause the standard
199.Pa passwd.byname
200and
201.Pa passwd.byuid
202maps to be generated with valid encrypted password fields, which is
203necessary in order for
204.No non- Ns Tn FreeBSD
205clients to perform user
206authentication through
207.Tn NIS .
208.El
209.Pp
210.Ss Security
211In general, any remote user can issue an RPC to
212.Nm
213and retrieve the contents of your
214.Tn NIS
215maps, provided the remote user
216knows your domain name. To prevent such unauthorized transactions,
217.Nm
218supports a feature called
219.Pa securenets
220which can be used to restrict access to a given set of hosts.
221At startup,
222.Nm
223will attempt to load the securenets information from a file
224called
225.Pa /var/yp/securenets .
226(Note that this path varies depending on the path specified with
227the
228.Fl p
229option, which is explained below.) This file contains entries
230that consist of a network specification and a network mask separated
231by white space.
232Lines starting with
233.Dq \&#
234are considered to be comments. A
235sample securenets file might look like this:
236.Bd -unfilled -offset indent
237# allow connections from local host -- mandatory
238127.0.0.1     255.255.255.255
239# allow connections from any host
240# on the 192.168.128.0 network
241192.168.128.0 255.255.255.0
242# allow connections from any host
243# between 10.0.0.0 to 10.0.15.255
24410.0.0.0      255.255.240.0
245.Ed
246.Pp
247If
248.Nm
249receives a request from an address that matches one of these rules,
250it will process the request normally. If the address fails to match
251a rule, the request will be ignored and a warning message will be
252logged. If the
253.Pa /var/yp/securenets
254file does not exist,
255.Nm
256will allow connections from any host.
257.Pp
258The
259.Nm
260program also has support for Wietse Venema's
261.Em tcpwrapper
262package, though it is not compiled in by default since
263the
264.Em tcpwrapper
265package is not distributed with
266.Fx .
267However, if you have
268.Pa libwrap.a
269and
270.Pa tcpd.h ,
271you can easily recompile
272.Nm
273with them. This allows the administrator to use the tcpwrapper
274configuration files (
275.Pa /etc/hosts.allow
276and
277.Pa /etc/hosts.deny )
278for access control instead of
279.Pa /var/yp/securenets .
280.Pp
281Note: while both of these access control mechanisms provide some
282security, they, like the privileged port test, are both vulnerable
283to
284.Dq IP spoofing
285attacks.
286.Pp
287.Ss NIS v1 compatibility
288This version of
289.Nm
290has some support for serving
291.Tn NIS
292v1 clients.
293The
294.Fx
295.Tn NIS
296implementation only uses the
297.Tn NIS
298v2 protocol, however other implementations
299include support for the v1 protocol for backwards compatibility
300with older systems. The
301.Xr ypbind 8
302daemons supplied with these systems will try to establish a binding
303to an
304.Tn NIS
305v1 server even though they may never actually need it (and they may
306persist in broadcasting in search of one even after they receive a
307response from a v2 server). Note that while
308support for normal client calls is provided, this version of
309.Nm
310does not handle v1 map transfer requests; consequently, it can not
311be used as a master or slave in conjunction with older
312.Tn NIS
313servers that
314only support the v1 protocol. Fortunately, there probably aren't any
315such servers still in use today.
316.Ss NIS servers that are also NIS clients
317Care must be taken when running
318.Nm
319in a multi-server domain where the server machines are also
320.Tn NIS
321clients. It is generally a good idea to force the servers to
322bind to themselves rather than allowing them to broadcast bind
323requests and possibly become bound to each other: strange failure
324modes can result if one server goes down and
325others are dependent upon on it. (Eventually all the clients will
326time out and attempt to bind to other servers, but the delay
327involved can be considerable and the failure mode is still present
328since the servers might bind to each other all over again).
329.Pp
330Refer to the
331.Xr ypbind 8
332man page for details on how to force it to bind to a particular
333server.
334.Sh OPTIONS
335The following options are supported by
336.Nm Ns :
337.Bl -tag -width flag
338.It Fl n
339This option affects the way
340.Nm
341handles yp_match requests for the
342.Pa hosts.byname
343and
344.Pa hosts.byaddress
345maps. By default, if
346.Nm
347can't find an entry for a given host in its hosts maps, it will
348return an error and perform no further processing. With the
349.Fl n
350flag,
351.Nm
352will go one step further: rather than giving up immediately, it
353will try to resolve the hostname or address using a DNS nameserver
354query. If the query is successful,
355.Nm
356will construct a fake database record and return it to the client,
357thereby making it seem as though the client's yp_match request
358succeeded.
359.Pp
360This feature is provided for compatiblity with SunOS 4.1.x,
361which has brain-damaged resolver functions in its standard C
362library that depend on
363.Tn NIS
364for hostname and address resolution.
365The
366.Fx
367resolver can be configured to do DNS
368queries directly, therefore it is not necessary to enable this
369option when serving only
370.Fx
371.Tn NIS
372clients.
373.It Fl d
374Cause the server to run in debugging mode. Normally,
375.Nm
376reports only unusual errors (access violations, file access failures)
377using the
378.Xr syslog 3
379facility. In debug mode, the server does not background
380itself and prints extra status messages to stderr for each
381request that it receives. Also, while running in debug mode,
382.Nm
383will not spawn any additional subprocesses as it normally does
384when handling yp_all requests or doing DNS lookups. (These actions
385often take a fair amount of time to complete and are therefore handled
386in subprocesses, allowing the parent server process to go on handling
387other requests.) This makes it easier to trace the server with
388a debugging tool.
389.It Fl p Ar path
390Normally,
391.Nm
392assumes that all
393.Tn NIS
394maps are stored under
395.Pa /var/yp .
396The
397.Fl p
398flag may be used to specify an alternate
399.Tn NIS
400root path, allowing
401the system administrator to move the map files to a different place
402within the filesystem.
403.El
404.Sh FILES
405.Bl -tag -width Pa -compact
406.It Pa /var/yp/[domainname]/[maps]
407the
408.Tn NIS
409maps
410.It Pa /etc/host.conf
411resolver configuration file
412.It Pa /var/yp/securenets
413host access control file
414.El
415.Sh SEE ALSO
416.Xr ypcat 1 ,
417.Xr db 3 ,
418.Xr yp 4 ,
419.Xr rpc.yppasswdd 8 ,
420.Xr ypbind 8 ,
421.Xr ypinit 8 ,
422.Xr yppush 8 ,
423.Xr ypxfr 8
424.Sh AUTHORS
425.An Bill Paul Aq wpaul@ctr.columbia.edu
426.Sh HISTORY
427This version of
428.Nm
429first appeared in
430.Fx 2.2 .
431