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