xref: /freebsd/usr.sbin/ypserv/ypserv.8 (revision e627b39baccd1ec9129690167cf5e6d860509655)
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.\"	$Id: ypserv.8,v 1.7 1996/04/07 00:06:21 mpp Exp $
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 ypserv
41.Op Fl n
42.Op Fl d
43.Op Fl p Ar path
44.Sh DESCRIPTION
45.Nm 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, NIS
55allows groups of computers to share one set of data which can be
56updated from a single location.
57.Pp
58.Nm ypserv
59is the server that distributes NIS databases
60to client systems within an NIS
61.Nm domain.
62Each client in an NIS domain must have its domainname set to
63one of the domains served by
64.Nm ypserv
65using the
66.Xr domainname 1
67command. The clients must also run
68.Xr ypbind 8
69in order to attach to a particular server, since it is possible to
70have serveral servers within a single NIS domain.
71.Pp
72The databases distributed by
73.Nm ypserv
74are stored in
75.Pa /var/yp/[domainname]
76where
77.Pa domainname
78is the name of the domain being served. There can be several
79such directories with different domainnames, and you need only one
80.Nm ypserv
81daemon to handle them all.
82.Pp
83The databases, or
84.Pa maps
85as they are often called,
86are created by
87.Nm /var/yp/Makefile
88using several system files as source. The database files are in
89.Xr db 3
90format to help speed retrieval when there are many records involved.
91In FreeBSD, the
92maps are always readable and writable only by root for security
93reasons. Technically this is only necessary for the password
94maps, but since the data in the other maps can be found in
95other world-readable files anyway, it doesn't hurt and it's considered
96good general practice.
97.Pp
98.Nm ypserv
99is started by
100.Nm /etc/rc
101if it has been enabled in
102.Nm /etc/sysconfig.
103.Sh SPECIAL FEATURES
104There are some problems associated with distributing FreeBSD's password
105database via NIS: FreeBSD normally only stores encrypted passwords
106in
107.Pa /etc/master.passwd ,
108which is readable and writable only by root. By turning this file
109into an NIS map, this security feature would be completely defeated.
110.Pp
111To make up for this, the FreeBSD version of
112.Nm ypserv
113handles the
114.Pa master.passwd.byname
115and
116.Pa master.basswd.byuid
117maps in a special way. When the server receives a request to access
118either of these two maps, it will check the TCP port from which the
119request originated and return an error if the port number is greater
120than 1023. Since only the superuser is allowed to bind to TCP ports
121with values less than 1024, the server can use this test to determine
122whether or not the access request came from a privileged user.
123Any requests made by non-privileged users are therefore rejected.
124.Pp
125Furthermore, the
126.Xr getpwent 3
127routines in FreeBSD's standard C libarary will only attempt to retrieve
128data from the
129.Pa master.passwd.byname
130and
131.Pa master.passwd.byuid
132maps for the superuser: if a normal user calls any of these functions,
133the standard
134.Pa passwd.byname
135and
136.Pa passwd.byuid
137maps will be accessed instead. The latter two maps are constructed by
138.Nm /var/yp/Makefile
139by parsing the
140.Pa master.passwd
141file and stripping out the password fields, and are therefore
142safe to pass on to unprivileged users. In this way, the shadow password
143aspect of the protected
144.Pa master.passwd
145database is maintained through NIS.
146.Pp
147.Sh NOTES
148.Ss Limitations
149There are two problems inherent with password shadowing in NIS
150that users should
151be aware of:
152.Bl -enum -offset indent
153.It
154The 'TCP port less than 1024' test is trivial to defeat for users with
155unrestricted access to machines on your network (even those machines
156which do not run UNIX-based operating systems).
157.It
158If you plan to use a FreeBSD system to serve non-FreeBSD clients that
159have no support for password shadowing (which is most of them), you
160will have to disable the password shadowing entirely by uncommenting the
161.Nm UNSECURE=True
162entry in
163.Nm /var/yp/Makefile .
164This will cause the standard
165.Pa passwd.byname
166and
167.Pa passwd.byuid
168maps to be generated with valid encrypted password fields, which is
169neccesary in order for non-FreeBSD clients to perform user
170authentication through NIS.
171.El
172.Pp
173.Ss Security
174In general, any remote user can issue an RPC to
175.Nm ypserv
176and retrieve the contents of your NIS maps, provided the remote user
177knows your domain name. To prevent such unauthorized transactions,
178.Nm ypserv
179supports a feature called
180.Pa securenets
181which can be used to restrict access to a given set of hosts.
182At startup,
183.Nm ypserv
184will attempt to load the securenets information from a file
185called
186.Nm /var/yp/securenets .
187(Note that this path varies depending on the path specified with
188the
189.Fl p
190option, which is explained below.) This file contains entries
191that consist of a network specification and a network mask separated
192by white space.
193Lines starting with ``#'' are considered to be comments. A
194sample securenets file might look like this:
195.Bd -unfilled -offset indent
196# allow connections from local host -- mandatory
197127.0.0.1     255.255.255.255
198# allow connections from any host
199# on the 129.168.128.0 network
200192.168.128.0 255.255.255.0
201# allow connections from any host
202# between 10.0.0.0 to 10.0.15.255
20310.0.0.0      255.255.240.0
204.Ed
205.Pp
206If
207.Nm ypserv
208receives a request from an address that matches one of these rules,
209it will process the request normally. If the address fails to match
210a rule, the request will be ignored and a warning message will be
211logged. If the
212.Pa /var/yp/securenets
213file does not exist,
214.Nm ypserv
215will allow connections from any host.
216.Pp
217.Nm Ypserv
218also has support for Wietse Venema's
219.Pa tcpwrapper
220package, though it is not compiled in by default since
221the
222.Pa tcpwrapper
223package is not distributed with FreeBSD. However, if you have
224.Nm libwrap.a
225and
226.Nm tcpd.h ,
227you can easily recompile
228.Nm ypserv
229with them. This allows the administrator to use the tcpwrapper
230configuration files (
231.Pa /etc/hosts.allow
232and
233.Pa /etc/hosts.deny )
234for access control instead of
235.Pa /var/yp/securenets .
236.Pp
237Note: while both of these access control mechanisms provide some
238security, they, like the privileged port test, are both vulnerable
239to ``IP spoofing'' attacks.
240.Pp
241.Ss NIS v1 compatibility
242This version of
243.Nm ypserv
244has some support for serving NIS v1 clients. FreeBSD's NIS
245implementation only uses the NIS v2 protocol, however other implementations
246include support for the v1 protocol for backwards compatibility
247with older systems. The
248.Xr ypbind 8
249daemons supplied with these systems will try to establish a binding
250to an NIS v1
251server even though they may never actually need it (and they may
252persist in broadcasting in search of one even after they receive a
253response from a v2 server). Note that while
254support for normal client calls is provided, this version of
255.Nm ypserv
256does not handle v1 map transfer requests; consequently, it can not
257be used as a master or slave in conjunction with older NIS servers that
258only support the v1 protocol. Fortunately, there probably aren't any
259such servers still in use today.
260.Ss NIS servers that are also NIS clients
261Care must be taken when running
262.Nm ypserv
263in a multi-server domain where the server machines are also
264NIS clients. It is generally a good idea to force the servers to
265bind to themselves rather than allowing them to broadcast bind
266requests and possibly become bound to each other: strange failure
267modes can result if one server goes down and
268others are dependent upon on it. (Eventually all the clients will
269time out and attempt to bind to other servers, but the delay
270involved can be considerable and the failure mode is still present
271since the servers might bind to each other all over again).
272.Pp
273Refer to the
274.Xr ypbind 8
275man page for details on how to force it to bind to a particular
276server.
277.Sh OPTIONS
278The following options are supported by
279.Nm ypserv :
280.Bl -tag -width flag
281.It Fl n
282This option affects the way
283.Nm ypserv
284handles yp_match requests for the
285.Pa hosts.byname
286and
287.Pa hosts.byaddress
288maps. By default, if
289.Nm ypserv
290can't find an entry for a given host in its hosts maps, it will
291return an error and perform no further processing. With the
292.Fl n
293flag,
294.Nm ypserv
295will go one step further: rather than giving up immediately, it
296will try to resolve the hostname or address using a DNS nameserver
297query. If the query is successful,
298.Nm ypserv
299will construct a fake database record and return it to the client,
300thereby making it seem as though the client's yp_match request
301succeeded.
302.Pp
303This feature is provided for compatiblity with SunOS 4.1.x,
304which has brain-damaged resolver functions in its standard C
305library that depend on NIS for hostname and address resolution.
306FreeBSD's resolver can be configured to do DNS
307queries directly, therefore it is not necessary to enable this
308option when serving only FreeBSD NIS clients.
309.It Fl d
310Causes the server to run in debugging mode. Normally,
311.Nm ypserv
312reports only unusual errors (access violations, file access failures)
313using the
314.Xr syslog 3
315facility. In debug mode, the server does not background
316itself and prints extra status messages to stderr for each
317request that it revceives. Also, while running in debug mode,
318.Nm ypserv
319will not spawn any additional subprocesses as it normally does
320when handling yp_all requests or doing DNS lookups. (These actions
321often take a fair amount of time to complete and are therefore handled
322in subprocesses, allowing the parent server process to go on handling
323other requests.) This makes it easier to trace the server with
324a debugging tool.
325.It Fl p Ar path
326Normally,
327.Nm ypserv
328assumes that all NIS maps are stored under
329.Pa /var/yp .
330The
331.Fl p
332flag may be used to specify an alternate NIS root path, allowing
333the system administrator to move the map files to a different place
334within the filesystem.
335.El
336.Sh FILES
337.Bl -tag -width Pa -compact
338.It Pa /var/yp/[domainname]/[maps]
339The NIS maps.
340.It Pa /etc/host.conf
341Resolver configuration file.
342.It Pa /var/yp/securenets
343Host access control file
344.El
345.Sh SEE ALSO
346.Xr ypcat 1 ,
347.Xr db 3 ,
348.Xr yp 4 ,
349.Xr ypbind 8 ,
350.Xr yppasswdd 8 ,
351.Xr yppush 8 ,
352.Xr ypxfr 8
353.Sh AUTHOR
354Bill Paul <wpaul@ctr.columbia.edu>
355.Sh HISTORY
356This version of
357.Nm ypserv
358first appeared in
359.Fx 2.2 .
360