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.6 1996/04/08 04:18:09 mpp 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.Xr bootparamd 8 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.Pa /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 separate 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.Em 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 165within 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.Fn yp_order 184-- check the creation date of a particular map 185.It 186.Fn yp_master 187-- obtain the name of the NIS master server for a given 188map/domain 189.It 190.Fn yp_match 191-- lookup the data corresponding to a given in key in a particular 192map/domain 193.It 194.Fn yp_first 195-- obtain the first key/data pair in a particular map/domain 196.It 197.Fn 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 (the functions 202.Fn yp_first 203and 204.Fn yp_next 205can be used to do a sequential search of an NIS map) 206.It 207.Fn yp_all 208-- retrieve the entire contents of a map 209.El 210.Pp 211There are a few other requests which 212.Xr ypserv 8 213is capable of handling (i.e. acknowledge whether or not you can handle 214a particular domain (YPPROC_DOMAIN), or acknowledge only if you can 215handle the domain and be silent otherwise (YPPROC_DOMAIN_NONACK)) but 216these requests are usually generated only by 217.Xr ypbind 8 218and are not meant to be used by standard utilities. 219.Pp 220On networks with a large number of hosts, it is often a good idea to 221use a master server and several slaves rather than just a single master 222server. A slave server provides the exact same information as a master 223server: whenever the maps on the master server are updated, the new 224data should be propagated to the slave systems using the 225.Xr yppush 8 226command. The NIS Makefile ( 227.Pa /var/yp/Makefile ) 228will do this automatically if the administrator comments out the 229line which says 230.Nm NOPUSH=true 231(NOPUSH is set to true by default because the default configuration is 232for a small network with only one NIS server). The 233.Xr yppush 8 234command will initiate a transaction between the master and slave 235during which the slave will transfer the specified maps from the 236master server using 237.Xr ypxfr 8 . 238(The slave server calls 239.Xr ypxfr 8 240automatically from within 241.Xr ypserv 8 ; 242therefore it is not usually necessary for the administrator 243to use it directly. It can be run manually if 244desired, however.) Maintaining 245slave servers helps improve NIS performance on large 246networks by: 247.Pp 248.Bl -bullet -offset indent 249.It 250Providing backup services in the event that the NIS master crashes 251or becomes unreachable 252.It 253Spreading the client load out over several machines instead of 254causing the master to become overloaded 255.It 256Allowing a single NIS domain to extend beyond 257a local network (the 258.Xr ypbind 8 259daemon might not be able to locate a server automatically if it resides on 260a network outside the reach of its broadcasts. It is possible to force 261.Xr ypbind 8 262to bind to a particular server with 263.Xr ypset 8 264but this is sometimes inconvenient. This problem can be avoided simply by 265placing a slave server on the local network.) 266.El 267.Pp 268The FreeBSD 269.Xr ypserv 8 270is specially designed to provided enhanced security (compared to 271other NIS implementations) when used exclusively with FreeBSD client 272systems. The FreeBSD password database system (which is derived directly 273from 274.Bx 4.4 ) 275includes support for 276.Em "shadow passwords" . 277The standard password database does not contain users' encrypted 278passwords: these are instead stored (along with other information) 279is a separate database which is accessible only by the super-user. 280If the encrypted password database were made available as an NIS 281map, this security feature would be totally disabled, since any user 282is allowed to retrieve NIS data. 283.Pp 284To help prevent this, FreeBSD's NIS server 285handles the shadow password maps ( 286.Pa master.passwd.byname 287and 288.Pa master.passwd.byuid ) 289in a special way: the server will only provide access to these 290maps in response to requests that originate on privileged ports. 291Since only the super-user is allowed to bind to a privileged port, 292the server assumes that all such requests come from privileged 293users. All other requests are denied: requests from non-privileged 294ports will receive only an error code from the server. Additionally, 295FreeBSD's 296.Xr ypserv 8 297includes support for Wietse Venema's tcp wrapper package; with tcp 298wrapper support enabled, the administrator can configure 299.Xr ypserv 8 300to respond only to selected client machines. 301.Pp 302While these enhancements provide better security than stock NIS, 303they are by no means 100% effective. It is still possible for 304someone with access to your network to spoof the server into disclosing 305the shadow password maps. 306.Pp 307On the client side, FreeBSD's 308.Fn getpwent 3 309functions will automatically search for the 310.Pa master.passwd 311maps and use them if they exist. If they do, they will be used, and 312all fields in these special maps (class, password age and account 313expiration) will be decoded. If they aren't found, the standard 314.Pa passwd 315maps will be used instead. 316.Sh COMPATIBILITY 317Some systems, such as SunOS 4.x, need NIS to be running in order 318for their hostname resolution functions ( 319.Fn gethostbyname , 320.Fn gethostbyaddr , 321etc) to work properly. On these systems, 322.Xr ypserv 8 323performs DNS lookups when asked to return information about 324a host that doesn't exist in its 325.Pa hosts.byname 326or 327.Pa hosts.byaddr 328maps. FreeBSD's resolver uses DNS by default (it can be made to use 329NIS, if desired), therefore its NIS server doesn't do DNS lookups 330by default. However, 331.Xr ypserv 8 332can be made to perform DNS lookups if it is started with a special 333flag. It can also be made to register itself as an NIS v1 server 334in order to placate certain systems that insist on the presence of 335a v1 server (FreeBSD uses only NIS v2, but many other systems, 336including SunOS 4.x, search for both a v1 and v2 server when binding). 337FreeBSD's 338.Xr ypserv 8 339does not actually handle NIS v1 requests, but this ``kludge mode'' 340is useful for silencing stubborn systems that search for both 341a v1 and v2 server. 342.Pp 343(Please see the 344.Xr ypserv 8 345manual page for a detailed description of these special features 346and flags.) 347.Sh BUGS 348While FreeBSD now has both NIS client and server capabilities, 349it does not yet have support for 350.Nm ypupdated 351or the 352.Fn yp_update 353function. Both of these require secure RPC, which FreeBSD doesn't 354support yet either. 355.Pp 356The 357.Xr getservent 3 358and 359.Xr getprotoent 3 360functions do not yet have NIS support. Fortunately, these files 361don't need to be updated that often. 362.Pp 363Many more manual pages should be written, especially 364.Xr ypclnt 3 . 365For the time being, seek out a local Sun machine and read the 366manuals for there. 367.Pp 368FreeBSD's server-side support is based on GPL'ed code originally 369written for Linux. It really needs its own implementation that is not 370subject to the GPL. 371.Pp 372Neither Sun nor this author have found a clean way to handle 373the problems that occur when ypbind cannot find its server 374upon bootup. 375.Sh HISTORY 376The 377.Nm YP 378subsystem was written from the ground up by Theo de Raadt 379to be compatible to Sun's implementation. Bug fixes, improvements 380and NIS server support were later added by Bill Paul. The server-side 381code was originally written by Peter Eriksson and Tobias Reber and 382is subject to the GNU Public License. No Sun code was 383referenced. 384