1afe61c15SRodney W. Grimes.\" Copyright (c) 1988, 1991, 1993 2afe61c15SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 3afe61c15SRodney W. Grimes.\" 4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions 6afe61c15SRodney W. Grimes.\" are met: 7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 8afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 10afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 11afe61c15SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12afe61c15SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 13afe61c15SRodney W. Grimes.\" must display the following acknowledgement: 14afe61c15SRodney W. Grimes.\" This product includes software developed by the University of 15afe61c15SRodney W. Grimes.\" California, Berkeley and its contributors. 16afe61c15SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 17afe61c15SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 18afe61c15SRodney W. Grimes.\" without specific prior written permission. 19afe61c15SRodney W. Grimes.\" 20afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23afe61c15SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30afe61c15SRodney W. Grimes.\" SUCH DAMAGE. 31afe61c15SRodney W. Grimes.\" 32f274239bSGarrett Wollman.\" From: @(#)passwd.5 8.1 (Berkeley) 6/5/93 33dd5527c6SMike Pritchard.\" $Id: passwd.5,v 1.15 1997/03/14 02:37:27 mpp Exp $ 34afe61c15SRodney W. Grimes.\" 35f274239bSGarrett Wollman.Dd September 29, 1994 36afe61c15SRodney W. Grimes.Dt PASSWD 5 37afe61c15SRodney W. Grimes.Os 38afe61c15SRodney W. Grimes.Sh NAME 39afe61c15SRodney W. Grimes.Nm passwd 40afe61c15SRodney W. Grimes.Nd format of the password file 41afe61c15SRodney W. Grimes.Sh DESCRIPTION 42afe61c15SRodney W. GrimesThe 43afe61c15SRodney W. Grimes.Nm passwd 44afe61c15SRodney W. Grimesfiles are files consisting of newline separated records, one per user, 45afe61c15SRodney W. Grimescontaining ten colon (``:'') separated fields. These fields are as 46afe61c15SRodney W. Grimesfollows: 47afe61c15SRodney W. Grimes.Pp 48afe61c15SRodney W. Grimes.Bl -tag -width password -offset indent 49afe61c15SRodney W. Grimes.It name 50afe61c15SRodney W. GrimesUser's login name. 51afe61c15SRodney W. Grimes.It password 52afe61c15SRodney W. GrimesUser's 53afe61c15SRodney W. Grimes.Em encrypted 54afe61c15SRodney W. Grimespassword. 55afe61c15SRodney W. Grimes.It uid 56afe61c15SRodney W. GrimesUser's id. 57afe61c15SRodney W. Grimes.It gid 58afe61c15SRodney W. GrimesUser's login group id. 59afe61c15SRodney W. Grimes.It class 60408bc30dSDavid NugentUser's login class. 61afe61c15SRodney W. Grimes.It change 62afe61c15SRodney W. GrimesPassword change time. 63afe61c15SRodney W. Grimes.It expire 64afe61c15SRodney W. GrimesAccount expiration time. 65afe61c15SRodney W. Grimes.It gecos 66afe61c15SRodney W. GrimesGeneral information about the user. 67afe61c15SRodney W. Grimes.It home_dir 68afe61c15SRodney W. GrimesUser's home directory. 69afe61c15SRodney W. Grimes.It shell 70afe61c15SRodney W. GrimesUser's login shell. 71afe61c15SRodney W. Grimes.El 72afe61c15SRodney W. Grimes.Pp 73f57cc79dSMike PritchardLines whose first non-whitespace character is a pound-sign (#) 74f57cc79dSMike Pritchardare comments, and are ignored. Blank lines which consist 750b65a998SMike Pritchardonly of spaces, tabs or newlines are also ignored. 7622bf9812SWolfram Schneider.Pp 77afe61c15SRodney W. GrimesThe 78afe61c15SRodney W. Grimes.Ar name 79afe61c15SRodney W. Grimesfield is the login used to access the computer account, and the 80afe61c15SRodney W. Grimes.Ar uid 81afe61c15SRodney W. Grimesfield is the number associated with it. They should both be unique 82afe61c15SRodney W. Grimesacross the system (and often across a group of systems) since they 83afe61c15SRodney W. Grimescontrol file access. 84afe61c15SRodney W. Grimes.Pp 85afe61c15SRodney W. GrimesWhile it is possible to have multiple entries with identical login names 86afe61c15SRodney W. Grimesand/or identical user id's, it is usually a mistake to do so. Routines 87afe61c15SRodney W. Grimesthat manipulate these files will often return only one of the multiple 88afe61c15SRodney W. Grimesentries, and that one by random selection. 89afe61c15SRodney W. Grimes.Pp 90afe61c15SRodney W. GrimesThe login name must never begin with a hyphen (``-''); also, it is strongly 91afe61c15SRodney W. Grimessuggested that neither upper-case characters or dots (``.'') be part 92afe61c15SRodney W. Grimesof the name, as this tends to confuse mailers. No field may contain a 93afe61c15SRodney W. Grimescolon (``:'') as this has been used historically to separate the fields 94afe61c15SRodney W. Grimesin the user database. 95afe61c15SRodney W. Grimes.Pp 96afe61c15SRodney W. GrimesThe password field is the 97afe61c15SRodney W. Grimes.Em encrypted 98afe61c15SRodney W. Grimesform of the password. 99afe61c15SRodney W. GrimesIf the 100afe61c15SRodney W. Grimes.Ar password 101afe61c15SRodney W. Grimesfield is empty, no password will be required to gain access to the 102afe61c15SRodney W. Grimesmachine. This is almost invariably a mistake. 103afe61c15SRodney W. GrimesBecause these files contain the encrypted user passwords, they should 104afe61c15SRodney W. Grimesnot be readable by anyone without appropriate privileges. 105408bc30dSDavid NugentAdministrative accounts have a password field containing an asterisk 106408bc30dSDavid Nugent.Ql \&* 107408bc30dSDavid Nugentwhich disallows normal logins. 108afe61c15SRodney W. Grimes.Pp 109afe61c15SRodney W. GrimesThe group field is the group that the user will be placed in upon login. 110408bc30dSDavid NugentAlthough this system supports multiple groups (see 111afe61c15SRodney W. Grimes.Xr groups 1 ) 112408bc30dSDavid Nugentthis field nominates the user's primary groups. 113408bc30dSDavid NugentSecondary group memberships are selected in 114408bc30dSDavid Nugent.Pa /etc/group . 115afe61c15SRodney W. Grimes.Pp 116afe61c15SRodney W. GrimesThe 117afe61c15SRodney W. Grimes.Ar class 118408bc30dSDavid Nugentfield is a key for a user's login class. 119408bc30dSDavid NugentLogin classes are defined in 120408bc30dSDavid Nugent.Xr login.conf 5 , 121408bc30dSDavid Nugentwhich is a 122afe61c15SRodney W. Grimes.Xr termcap 5 123408bc30dSDavid Nugentstyle database of user attributes, accounting, resource and 124408bc30dSDavid Nugentenvironment settings. 125afe61c15SRodney W. Grimes.Pp 126afe61c15SRodney W. GrimesThe 127afe61c15SRodney W. Grimes.Ar change 128afe61c15SRodney W. Grimesfield is the number in seconds, 129afe61c15SRodney W. Grimes.Dv GMT , 130afe61c15SRodney W. Grimesfrom the epoch, until the 131afe61c15SRodney W. Grimespassword for the account must be changed. 132408bc30dSDavid NugentThis field may be left empty or set to 0 to turn off the 133408bc30dSDavid Nugentpassword aging feature. 134afe61c15SRodney W. Grimes.Pp 135afe61c15SRodney W. GrimesThe 136afe61c15SRodney W. Grimes.Ar expire 137afe61c15SRodney W. Grimesfield is the number in seconds, 138afe61c15SRodney W. Grimes.Dv GMT , 139afe61c15SRodney W. Grimesfrom the epoch, until the 140afe61c15SRodney W. Grimesaccount expires. 141408bc30dSDavid NugentThis field may be left empty or set to 0 to turn off the account 142408bc30dSDavid Nugentaging feature. 143afe61c15SRodney W. Grimes.Pp 144afe61c15SRodney W. GrimesThe 145afe61c15SRodney W. Grimes.Ar gecos 146afe61c15SRodney W. Grimesfield normally contains comma (``,'') separated subfields as follows: 147afe61c15SRodney W. Grimes.Pp 148afe61c15SRodney W. Grimes.Bd -unfilled -offset indent 149408bc30dSDavid Nugentfullname user's full name 150afe61c15SRodney W. Grimesoffice user's office number 151afe61c15SRodney W. Grimeswphone user's work phone number 152afe61c15SRodney W. Grimeshphone user's home phone number 153afe61c15SRodney W. Grimes.Ed 154afe61c15SRodney W. Grimes.Pp 155afe61c15SRodney W. GrimesThis information is used by the 156afe61c15SRodney W. Grimes.Xr finger 1 157408bc30dSDavid Nugentprogram, and the first field used by the system mailer. 158408bc30dSDavid NugentIf an ampersand 159408bc30dSDavid Nugent.Ql \&& 160408bc30dSDavid Nugentcharacter appears within the fullname field, programs which 161408bc30dSDavid Nugentuse this field will substitute it with a capitalized version 162408bc30dSDavid Nugentof the account's login name. 163afe61c15SRodney W. Grimes.Pp 164afe61c15SRodney W. GrimesThe user's home directory is the full 165afe61c15SRodney W. Grimes.Tn UNIX 166afe61c15SRodney W. Grimespath name where the user 167afe61c15SRodney W. Grimeswill be placed on login. 168afe61c15SRodney W. Grimes.Pp 169afe61c15SRodney W. GrimesThe shell field is the command interpreter the user prefers. 170afe61c15SRodney W. GrimesIf there is nothing in the 171afe61c15SRodney W. Grimes.Ar shell 172afe61c15SRodney W. Grimesfield, the Bourne shell 173afe61c15SRodney W. Grimes.Pq Pa /bin/sh 174afe61c15SRodney W. Grimesis assumed. 175623899a3SMike PritchardFor security reasons, if the shell is set to a script that disallows 176623899a3SMike Pritchardaccess to the system (the 177623899a3SMike Pritchard.Xr nologin 8 178623899a3SMike Pritchardscript, for example), care should be taken not to import any environment 179623899a3SMike Pritchardvariables. With 180623899a3SMike Pritchard.Xr sh 1 , 181623899a3SMike Pritchardthis can be done by specifying the 182623899a3SMike Pritchard.Fl p 183623899a3SMike Pritchardflag. 184623899a3SMike PritchardCheck the specific shell documentation to determine how this is 185623899a3SMike Pritcharddone with other shells. 186f274239bSGarrett Wollman.Sh YP/NIS INTERACTION 187a755ea5bSBill Paul.Ss Enabling access to NIS passwd data 188dd5527c6SMike PritchardThe system administrator can configure 189dd5527c6SMike Pritchard.Tn FreeBSD 190dd5527c6SMike Pritchardto use NIS/YP for 191a755ea5bSBill Paulits password information by adding special records to the 192f274239bSGarrett Wollman.Pa /etc/master.passwd 193a755ea5bSBill Paulfile. These entries should be added with 194a755ea5bSBill Paul.Xr vipw 8 195a755ea5bSBill Paulso that the changes can be properly merged with the hashed 196a755ea5bSBill Paulpassword databases and the 197a755ea5bSBill Paul.Pa /etc/passwd 198a755ea5bSBill Paulfile ( 199a755ea5bSBill Paul.Pa /etc/passwd 200a755ea5bSBill Paulshould never be edited manually). Alternatively, the administrator 201a755ea5bSBill Paulcan modify 202a755ea5bSBill Paul.Pa /etc/master.passwd 203a755ea5bSBill Paulin some other way and then manually update the password databases with 204a755ea5bSBill Paul.Xr pwd_mkdb 8 . 205a755ea5bSBill Paul.Pp 206a755ea5bSBill PaulThe simplest way to activate NIS is to add an empty record 207a755ea5bSBill Paulwith only a plus sign (`+') in the name field, such as this: 208f274239bSGarrett Wollman.Bd -literal -offset indent 209a755ea5bSBill Paul+::::::::: 210f274239bSGarrett Wollman 211f274239bSGarrett Wollman.Ed 212a755ea5bSBill PaulThe `+' will tell the 213a755ea5bSBill Paul.Xr getpwent 3 214dd5527c6SMike Pritchardroutines in 215dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 216dd5527c6SMike Pritchardstandard C library to begin using the NIS passwd maps 217a755ea5bSBill Paulfor lookups. 218f274239bSGarrett Wollman.Pp 219a755ea5bSBill PaulNote that the entry shown above is known as a 220a755ea5bSBill Paul.Pa wildcard 221a755ea5bSBill Paulentry, because it matches all users (the `+' without any other information 222a755ea5bSBill Paulmatches everybody) and allows all NIS password data to be retrieved 223a755ea5bSBill Paulunaltered. However, by 224a755ea5bSBill Paulspecifying a username or netgroup next to the `+' in the NIS 225a755ea5bSBill Paulentry, the administrator can affect what data is extracted from the 226a755ea5bSBill PaulNIS passwd maps and how it is interpreted. Here are a few example 227a755ea5bSBill Paulrecords that illustrate this feature (note that you can have several 228a755ea5bSBill PaulNIS entries in a single 229a755ea5bSBill Paul.Pa master.passwd 230a755ea5bSBill Paulfile): 231a755ea5bSBill Paul.Bd -literal -offset indent 232a755ea5bSBill Paul-mitnick::::::::: 233a755ea5bSBill Paul+@staff::::::::: 234a755ea5bSBill Paul+@permitted-users::::::::: 235a755ea5bSBill Paul+dennis::::::::: 236a755ea5bSBill Paul+ken:::::::::/bin/csh 237a755ea5bSBill Paul+@rejected-users::32767:32767::::::/bin/false 238a755ea5bSBill Paul 239a755ea5bSBill Paul.Ed 240623899a3SMike PritchardSpecific usernames are listed explicitly while netgroups are signified 2414a8d0283SMike Pritchardby a preceding `@'. In the above example, users in the ``staff'' and 242a755ea5bSBill Paul``permitted-users'' netgroups will have their password information 2434a8d0283SMike Pritchardread from NIS and used unaltered. In other words, they will be allowed 244a755ea5bSBill Paulnormal access to the machine. Users ``ken'' and ``dennis,'' who have 2454a8d0283SMike Pritchardbeen named explicitly rather than through a netgroup, will also have 246a755ea5bSBill Paultheir password data read from NIS, _except_ that user ``ken'' will 247a755ea5bSBill Paulhave his shell remapped to 248a755ea5bSBill Paul.Pa /bin/csh . 249a755ea5bSBill PaulThis means that value for his shell specified in the NIS password map 2504a8d0283SMike Pritchardwill be overridden by the value specified in the special NIS entry in 251a755ea5bSBill Paulthe local 252a755ea5bSBill Paul.Pa master.passwd 253a755ea5bSBill Paulfile. User ``ken'' may have been assigned the csh shell because his 254a755ea5bSBill PaulNIS password entry specified a different shell that may not be 255a755ea5bSBill Paulinstalled on the client machine for political or technical reasons. 256a755ea5bSBill PaulMeanwhile, users in the ``rejected-users'' netgroup are prevented 257a755ea5bSBill Paulfrom logging in because their UIDs, GIDs and shells have been overridden 258a755ea5bSBill Paulwith invalid values. 259a755ea5bSBill Paul.Pp 260a755ea5bSBill PaulUser ``mitnick'' will be be ignored entirely because his entry is 261a755ea5bSBill Paulspecified with a `-' instead of a `+'. A minus entry can be used 262a755ea5bSBill Paulto block out certain NIS password entries completely; users who's 263a755ea5bSBill Paulpassword data has been excluded in this way are not recognized by 264a755ea5bSBill Paulthe system at all. (Any overrides specified with minus entries are 265a755ea5bSBill Paulalso ignored since there is no point in processing override information 266a755ea5bSBill Paulfor a user that the system isn't going to recognize in the first place.) 267a755ea5bSBill PaulIn general, a minus entry is used to specifically exclude a user 268a755ea5bSBill Paulwho might otherwise be granted access because he happens to be a 269a755ea5bSBill Paulmember of an authorized netgroup. For example, if ``mitnick'' is 270a755ea5bSBill Paula member of the ``permitted-users'' netgroup and must, for whatever 271a755ea5bSBill Paulthe reason, be permitted to remain in that netgroup (possibly to 2724a8d0283SMike Pritchardretain access to other machines within the domain), the administrator 273a755ea5bSBill Paulcan still deny him access to a particular system with a minus entry. 274a755ea5bSBill PaulAlso, it is sometimes easier to explicitly list those users who aren't 275a755ea5bSBill Paulallowed access rather than generate a possibly complicated list of 276a755ea5bSBill Paulusers who are allowed access and omit the rest. 277a755ea5bSBill Paul.Pp 278a755ea5bSBill PaulNote that the plus and minus entries are evaluated in order from 279a755ea5bSBill Paulfirst to last with the first match taking precedence. This means 280a755ea5bSBill Paulthat the system will only use the first entry which matches a particular user. 281a755ea5bSBill PaulIf, for instance, we have a user ``foo'' who is a member of both the ``staff'' 282a755ea5bSBill Paulnetgroup and the ``rejected-users'' netgroup, he will be admitted to 283a755ea5bSBill Paulthe system because the above example lists the entry for ``staff'' 284a755ea5bSBill Paulbefore the entry for ``rejected-users.'' If we reversed the order, 285a755ea5bSBill Pauluser ``foo'' would be flagged as a ``rejected-user'' instead and 286a755ea5bSBill Pauldenied access. 287a755ea5bSBill Paul.Pp 288a755ea5bSBill PaulLastly, any NIS password database records that do not match against 289a755ea5bSBill Paulat least one of the users or netgroups specified by the NIS access 290a755ea5bSBill Paulentries in the 291a755ea5bSBill Paul.Pa /etc/master.passwd 292a755ea5bSBill Paulfile will be ignored (along with any users specified using minus 293a755ea5bSBill Paulentries). In our example shown above, we do not have a wildcard 294a755ea5bSBill Paulentry at the end of the list; therefore, the system will not recognize 295a755ea5bSBill Paulanyone except 296a755ea5bSBill Paul``ken,'' ``dennis,'' the ``staff'' netgroup and the ``permitted-users'' 297a755ea5bSBill Paulnetgroup as authorized users. The ``rejected-users'' netgroup will 298a755ea5bSBill Paulbe recognized but all members will have their shells remapped and 299a755ea5bSBill Paultherefore be denied access. 300a755ea5bSBill PaulAll other NIS password records 301a755ea5bSBill Paulwill be ignored. The administrator may add a wildcard entry to the 302a755ea5bSBill Paulend of the list such as: 303a755ea5bSBill Paul.Bd -literal -offset indent 304a755ea5bSBill Paul+:::::::::/usr/local/bin/go_away 305a755ea5bSBill Paul 306a755ea5bSBill Paul.Ed 307a755ea5bSBill PaulThis entry acts as a catch-all for all users that don't match against 308a755ea5bSBill Paulany of the other entries. 309a755ea5bSBill Paul.Pa /usr/local/bin/go_away 310a755ea5bSBill Paulcan be a short shell script or program 311a755ea5bSBill Paulthat prints a message telling the user that he is not allowed access 3124a8d0283SMike Pritchardto the system. This technique is sometimes useful when it is 3134a8d0283SMike Pritcharddesirable to have the system be able to recognize all users in a 314a755ea5bSBill Paulparticular NIS domain without necessarily granting them login access. 315623899a3SMike PritchardSee the above text on the shell field regarding security concerns when using 316623899a3SMike Pritcharda shell script as the login shell. 317a755ea5bSBill Paul.Pp 318a755ea5bSBill PaulThe primary use of this 319a755ea5bSBill Paul.Pa override 320a755ea5bSBill Paulfeature is to permit the administrator 321a755ea5bSBill Paulto enforce access restrictions on NIS client systems. Users can be 322a755ea5bSBill Paulgranted access to one group of machines and denied access to other 323a755ea5bSBill Paulmachines simply by adding or removing them from a particular netgroup. 324a755ea5bSBill PaulSince the netgroup database can also be accessed via NIS, this allows 325a755ea5bSBill Paulaccess restrictions to be administered from a single location, namely 326a755ea5bSBill Paulthe NIS master server; once a host's access list has been set in 327a755ea5bSBill Paul.Pa /etc/master.passwd , 328a755ea5bSBill Paulit need not be modified again unless new netgroups are created. 329a755ea5bSBill Paul.Sh NOTES 330a755ea5bSBill Paul.Ss Shadow passwords through NIS 331dd5527c6SMike Pritchard.Tn FreeBSD 332dd5527c6SMike Pritcharduses a shadow password scheme: users' encrypted passwords 333a755ea5bSBill Paulare stored only in 334a755ea5bSBill Paul.Pa /etc/master.passwd 335a755ea5bSBill Pauland 336a755ea5bSBill Paul.Pa /etc/spwd.db , 337a755ea5bSBill Paulwhich are readable and writable only by the superuser. This is done 338a755ea5bSBill Paulto prevent users from running the encrypted passwords through 339a755ea5bSBill Paulpassword-guessing programs and gaining unauthorized access to 340a755ea5bSBill Paulother users' accounts. NIS does not support a standard means of 341a755ea5bSBill Paulpassword shadowing, which implies that placing your password data 342dd5527c6SMike Pritchardinto the NIS passwd maps totally defeats the security of 343dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 344a755ea5bSBill Paulpassword shadowing system. 345a755ea5bSBill Paul.Pp 346dd5527c6SMike Pritchard.Tn FreeBSD 347dd5527c6SMike Pritchardprovides a few special features to help get around this 3484a8d0283SMike Pritchardproblem. It is possible to implement password shadowing between 349dd5527c6SMike Pritchard.Tn FreeBSD 350dd5527c6SMike PritchardNIS clients and 351dd5527c6SMike Pritchard.Tn FreeBSD 352dd5527c6SMike PritchardNIS servers. The 353a755ea5bSBill Paul.Xr getpwent 3 354a755ea5bSBill Paulroutines will search for a 355a755ea5bSBill Paul.Pa master.passwd.byname 356a755ea5bSBill Pauland 357a755ea5bSBill Paul.Pa master.passwd.byuid 358a755ea5bSBill Paulmaps which should contain the same data found in the 359a755ea5bSBill Paul.Pa /etc/master.passwd 360dd5527c6SMike Pritchardfile. If the maps exist, 361dd5527c6SMike Pritchard.Tn FreeBSD 362dd5527c6SMike Pritchardwill attempt to use them for user 363a755ea5bSBill Paulauthentication instead of the standard 364a755ea5bSBill Paul.Pa passwd.byname 365a755ea5bSBill Pauland 366a755ea5bSBill Paul.Pa passwd.byuid 367dd5527c6SMike Pritchardmaps. 368dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 369a755ea5bSBill Paul.Xr ypserv 8 370a755ea5bSBill Paulwill also check client requests to make sure they originate on a 371a755ea5bSBill Paulprivileged port. Since only the superuser is allowed to bind to 372a755ea5bSBill Paula privileged port, the server can tell if the requesting user 373a755ea5bSBill Paulis the superuser; all requests from non-privileged users to access 374a755ea5bSBill Paulthe 375a755ea5bSBill Paul.Pa master.passwd 376a755ea5bSBill Paulmaps will be refused. Since all user authentication programs run 377a755ea5bSBill Paulwith superuser privilege, they should have the required access to 378a755ea5bSBill Paulusers' encrypted password data while normal users will only 379a755ea5bSBill Paulbe allowed access to the standard 380a755ea5bSBill Paul.Pa passwd 381a755ea5bSBill Paulmaps which contain no password information. 382a755ea5bSBill Paul.Pp 383a755ea5bSBill PaulNote that this feature cannot be used in an environment with 384dd5527c6SMike Pritchard.No non- Ns Tn FreeBSD 385dd5527c6SMike Pritchardsystems. Note also that a truly determined user with 386a755ea5bSBill Paulunrestricted access to your network could still compromise the 387a755ea5bSBill Paul.Pa master.passwd 388a755ea5bSBill Paulmaps. 389a755ea5bSBill Paul.Ss UID and GID remapping with NIS overrides 390dd5527c6SMike PritchardUnlike 391dd5527c6SMike Pritchard.Tn SunOS 392dd5527c6SMike Pritchardand other operating systems that use Sun's NIS code, 393dd5527c6SMike Pritchard.Tn FreeBSD 394dd5527c6SMike Pritchardallows the user to override 395a755ea5bSBill Paul.Pa all 396a755ea5bSBill Paulof the fields in a user's NIS 397a755ea5bSBill Paul.Pa passwd 398a755ea5bSBill Paulentry. 399a755ea5bSBill PaulFor example, consider the following 400a755ea5bSBill Paul.Pa /etc/master.passwd 401a755ea5bSBill Paulentry: 402a755ea5bSBill Paul.Bd -literal -offset indent 403a755ea5bSBill Paul+@foo-users:???:666:666:0:0:0:Bogus user:/home/bogus:/bin/bogus 404a755ea5bSBill Paul 405a755ea5bSBill Paul.Ed 406a755ea5bSBill PaulThis entry will cause all users in the `foo-users' netgroup to 407a755ea5bSBill Paulhave 408a755ea5bSBill Paul.Pa all 4094a8d0283SMike Pritchardof their password information overridden, including UIDs, 410a755ea5bSBill PaulGIDs and passwords. The result is that all `foo-users' will be 411a755ea5bSBill Paullocked out of the system, since their passwords will be remapped 412a755ea5bSBill Paulto invalid values. 413a755ea5bSBill Paul.Pp 414a755ea5bSBill PaulThis is important to remember because most people are accustomed to 415a755ea5bSBill Paulusing an NIS wildcard entry that looks like this: 416a755ea5bSBill Paul.Bd -literal -offset indent 417a755ea5bSBill Paul+:*:0:0::: 418a755ea5bSBill Paul 419a755ea5bSBill Paul.Ed 420dd5527c6SMike PritchardThis often leads to new 421dd5527c6SMike Pritchard.Tn FreeBSD 422dd5527c6SMike Pritchardadministrators choosing NIS entries for their 423a755ea5bSBill Paul.Pa master.passwd 424a755ea5bSBill Paulfiles that look like this: 425a755ea5bSBill Paul.Bd -literal -offset indent 426a755ea5bSBill Paul+:*:0:0:::::: 427a755ea5bSBill Paul 428a755ea5bSBill Paul.Ed 429a755ea5bSBill PaulOr worse, this 430a755ea5bSBill Paul.Bd -literal -offset indent 431a755ea5bSBill Paul+::0:0:::::: 432a755ea5bSBill Paul 433a755ea5bSBill Paul.Ed 434dd5527c6SMike Pritchard.Sy DO _NOT_ PUT ENTRIES LIKE THIS IN YOUR 435dd5527c6SMike Pritchard.Sy Pa master.passwd 436dd5527c6SMike Pritchard.Sy FILE!! 437dd5527c6SMike PritchardThe first tells 438dd5527c6SMike Pritchard.Tn FreeBSD 439dd5527c6SMike Pritchardto remap all passwords to `*' (which 440a755ea5bSBill Paulwill prevent anybody from logging in) and to remap all UIDs and GIDs 441a755ea5bSBill Paulto 0 (which will make everybody appear to be the superuser). The 442a755ea5bSBill Paulsecond case just maps all UIDs and GIDs to 0, which means that 443a755ea5bSBill Paul.Pa all users will appear to be root! 444a755ea5bSBill Paul.Pp 445a755ea5bSBill Paul.Ss Compatibility of NIS override evaluation 446a755ea5bSBill PaulWhen Sun originally added NIS support to their 447a755ea5bSBill Paul.Xr getpwent 3 448dd5527c6SMike Pritchardroutines, they took into account the fact that the 449dd5527c6SMike Pritchard.Tn SunOS 450dd5527c6SMike Pritchardpassword 451a755ea5bSBill Paul.Pa /etc/passwd 452dd5527c6SMike Pritchardfile is in plain 453dd5527c6SMike Pritchard.Tn ASCII 454dd5527c6SMike Pritchardformat. The 455dd5527c6SMike Pritchard.Tn SunOS 456dd5527c6SMike Pritcharddocumentation claims that 457a755ea5bSBill Pauladding a '+' entry to the password file causes the contents of 458a755ea5bSBill Paulthe NIS password database to be 'inserted' at the position in 459a755ea5bSBill Paulthe file where the '+' entry appears. If, for example, the 460a755ea5bSBill Pauladministrator places the +:::::: entry in the middle of 461a755ea5bSBill Paul.Pa /etc/passwd, 462a755ea5bSBill Paulthen the entire contents of the NIS password map would appear 463a755ea5bSBill Paulas though it had been copied into the middle of the password 464a755ea5bSBill Paulfile. If the administrator places the +:::::: entry at both the 465a755ea5bSBill Paulmiddle and the end of 466a755ea5bSBill Paul.Pa /etc/passwd , 467a755ea5bSBill Paulthen the NIS password map would appear twice: once in the middle 468a755ea5bSBill Paulof the file and once at the end. (By using override entries 469a755ea5bSBill Paulinstead of simple wildcards, other combinations could be achieved.) 470a755ea5bSBill Paul.Pp 471dd5527c6SMike PritchardBy contrast, 472dd5527c6SMike Pritchard.Tn FreeBSD 473dd5527c6SMike Pritcharddoes not have a single 474dd5527c6SMike Pritchard.Tn ASCII 475dd5527c6SMike Pritchardpassword file: it 476a755ea5bSBill Paulhas a hashed password database. This database does not have an 477a755ea5bSBill Pauleasily-defined beginning, middle or end, which makes it very hard 478dd5527c6SMike Pritchardto design a scheme that is 100% compatible with 479dd5527c6SMike Pritchard.Tn SunOS . 480dd5527c6SMike PritchardFor example, 481a755ea5bSBill Paulthe 482a755ea5bSBill Paul.Fn getpwnam 483a755ea5bSBill Pauland 484f274239bSGarrett Wollman.Fn getpwuid 485dd5527c6SMike Pritchardfunctions in 486dd5527c6SMike Pritchard.Tn FreeBSD 487dd5527c6SMike Pritchardare designed to do direct queries to the 488a755ea5bSBill Paulhash database rather than a linear search. This approach is faster 489a755ea5bSBill Paulon systems where the password database is large. However, when 490a755ea5bSBill Paulusing direct database queries, the system does not know or care 491a755ea5bSBill Paulabout the order of the original password file, and therefore 492dd5527c6SMike Pritchardit cannot easily apply the same override logic used by 493dd5527c6SMike Pritchard.Tn SunOS . 494a755ea5bSBill Paul.Pp 495dd5527c6SMike PritchardInstead, 496dd5527c6SMike Pritchard.Tn FreeBSD 497dd5527c6SMike Pritchardgroups all the NIS override entries together 498a755ea5bSBill Pauland constructs a filter out of them. Each NIS password entry 499a755ea5bSBill Paulis compared against the override filter exactly once and 500a755ea5bSBill Paultreated accordingly: if the filter allows the entry through 501a755ea5bSBill Paulunaltered, it's treated unaltered; if the filter calls for remapping 502a755ea5bSBill Paulof fields, then fields are remapped; if the filter calls for 503a755ea5bSBill Paulexplicit exclusion (i.e. the entry matches a '-' override), 504a755ea5bSBill Paulthe entry is ignored; if the entry doesn't match against any 505a755ea5bSBill Paulof the filter specifications, it's discarded. 506a755ea5bSBill Paul.Pp 507a755ea5bSBill PaulAgain, note that the NIS '+' and '-' entries 508a755ea5bSBill Paulthemselves are handled in the order in which they were specified 509a755ea5bSBill Paulin the 510a755ea5bSBill Paul.Pa /etc/master.passwd 511a755ea5bSBill Paulfile since doing otherwise would lead to unpredicable behavior. 512a755ea5bSBill Paul.Pp 513dd5527c6SMike PritchardThe end result is that 514dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 515dd5527c6SMike Pritchardprovides a very close approximation 516dd5527c6SMike Pritchardof 517dd5527c6SMike Pritchard.Tn SunOS Ns 's 518dd5527c6SMike Pritchardbehavior while maintaining the database paradigm, though the 519a755ea5bSBill Paul.Xr getpwent 3 520dd5527c6SMike Pritchardfunctions do behave somewhat differently that their 521dd5527c6SMike Pritchard.Tn SunOS 522dd5527c6SMike Pritchardcounterparts. 523a755ea5bSBill PaulThe primary differences are: 524a755ea5bSBill Paul.Bl -bullet -offset indent 525a755ea5bSBill Paul.It 526a755ea5bSBill PaulEach NIS password map record can be mapped into the password 527a755ea5bSBill Paullocal password space only once. 528a755ea5bSBill Paul.It 529a755ea5bSBill PaulThe placement of the NIS '+' and '-' entries does not necessarily 530a755ea5bSBill Paulaffect where NIS password records will be mapped into 531a755ea5bSBill Paulthe password space. 532a755ea5bSBill Paul.El 533a755ea5bSBill Paul.Pp 534dd5527c6SMike PritchardIn %99 of all 535dd5527c6SMike Pritchard.Tn FreeBSD 536dd5527c6SMike Pritchardconfigurations, NIS client behavior will be 537dd5527c6SMike Pritchardindistinguishable from that of 538dd5527c6SMike Pritchard.Tn SunOS 539dd5527c6SMike Pritchardor other similar systems. Even 5404a8d0283SMike Pritchardso, users should be aware of these architectural differences. 541a755ea5bSBill Paul.Pp 542a755ea5bSBill Paul.Ss Using groups instead of netgroups for NIS overrides 543dd5527c6SMike Pritchard.Tn FreeBSD 544dd5527c6SMike Pritchardoffers the capability to do override matching based on 545a755ea5bSBill Pauluser groups rather than netgroups. If, for example, an NIS entry 546a755ea5bSBill Paulis specified as: 547a755ea5bSBill Paul.Bd -literal -offset indent 548a755ea5bSBill Paul+@operator::::::::: 549a755ea5bSBill Paul 550a755ea5bSBill Paul.Ed 551a755ea5bSBill Paulthe system will first try to match users against a netgroup called 552a755ea5bSBill Paul`operator.' If an `operator' netgroup doesn't exist, the system 553a755ea5bSBill Paulwill try to match users against the normal `operator' group 554a755ea5bSBill Paulinstead. 555dd5527c6SMike Pritchard.Ss Changes in behavior from older versions of 556dd5527c6SMike Pritchard.Tn FreeBSD 557dd5527c6SMike PritchardThere have been several bug fixes and improvements in 558dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 559a755ea5bSBill PaulNIS/YP handling, some of which have caused changes in behavior. 560a755ea5bSBill PaulWhile the behavior changes are generally positive, it is important 561a755ea5bSBill Paulthat users and system administrators be aware of them: 562a755ea5bSBill Paul.Bl -enum -offset indent 563a755ea5bSBill Paul.It 564a755ea5bSBill PaulIn versions prior to 2.0.5, reverse lookups (i.e. using 565a755ea5bSBill Paul.Fn getpwuid ) 566a755ea5bSBill Paulwould not have overrides applied, which is to say that it 567a755ea5bSBill Paulwas possible for 568a755ea5bSBill Paul.Fn getpwuid 569a755ea5bSBill Paulto return a login name that 570a755ea5bSBill Paul.Fn getpwnam 571a755ea5bSBill Paulwould not recognize. This has been fixed: overrides specified 572a755ea5bSBill Paulin 573a755ea5bSBill Paul.Pa /etc/master.passwd 574a755ea5bSBill Paulnow apply to all 575a755ea5bSBill Paul.Xr getpwent 3 576a755ea5bSBill Paulfunctions. 577a755ea5bSBill Paul.It 578dd5527c6SMike PritchardPrior to 579dd5527c6SMike Pritchard.Fx 2.0.5 , 580dd5527c6SMike Pritchardnetgroup overrides did not work at 581dd5527c6SMike Pritchardall, largely because 582dd5527c6SMike Pritchard.Tn FreeBSD 583dd5527c6SMike Pritcharddid not have support for reading 584a755ea5bSBill Paulnetgroups through NIS. Again, this has been fixed, and 585dd5527c6SMike Pritchardnetgroups can be specified just as in 586dd5527c6SMike Pritchard.Tn SunOS 587dd5527c6SMike Pritchardand similar NIS-capable 588a755ea5bSBill Paulsystems. 589a755ea5bSBill Paul.It 590dd5527c6SMike Pritchard.Tn FreeBSD 591dd5527c6SMike Pritchardnow has NIS server capabilities and supports the use 592a755ea5bSBill Paulof 593a755ea5bSBill Paul.Pa master.passwd 594a755ea5bSBill PaulNIS maps in addition to the standard Sixth Edition format 595a755ea5bSBill Paul.Pa passwd 596a755ea5bSBill Paulmaps. 597a755ea5bSBill PaulThis means that you can specify change, expiration and class 598dd5527c6SMike Pritchardinformation through NIS, provided you use a 599dd5527c6SMike Pritchard.Tn FreeBSD 600dd5527c6SMike Pritchardsystem as 601a755ea5bSBill Paulthe NIS server. 602a755ea5bSBill Paul.El 603f274239bSGarrett Wollman.Sh FILES 604f274239bSGarrett Wollman.Bl -tag -width /etc/master.passwd -compact 605f274239bSGarrett Wollman.It Pa /etc/passwd 606dd5527c6SMike Pritchard.Tn ASCII 607dd5527c6SMike Pritchardpassword file, with passwords removed 608f274239bSGarrett Wollman.It Pa /etc/pwd.db 609f274239bSGarrett Wollman.Xr db 3 -format 610f274239bSGarrett Wollmanpassword database, with passwords removed 611f274239bSGarrett Wollman.It Pa /etc/master.passwd 612dd5527c6SMike Pritchard.Tn ASCII 613dd5527c6SMike Pritchardpassword file, with passwords intact 614f274239bSGarrett Wollman.It Pa /etc/spwd.db 615f274239bSGarrett Wollman.Xr db 3 -format 616f274239bSGarrett Wollmanpassword database, with passwords intact 617f274239bSGarrett Wollman.El 618afe61c15SRodney W. Grimes.Sh SEE ALSO 619afe61c15SRodney W. Grimes.Xr chpass 1 , 620afe61c15SRodney W. Grimes.Xr login 1 , 621afe61c15SRodney W. Grimes.Xr passwd 1 , 622c69a537cSWolfram Schneider.Xr getpwent 3 , 623408bc30dSDavid Nugent.Xr login_getclass 3 , 624c69a537cSWolfram Schneider.Xr yp 4 , 625408bc30dSDavid Nugent.Xr login.conf 5 , 626c69a537cSWolfram Schneider.Xr adduser 8 , 627afe61c15SRodney W. Grimes.Xr pwd_mkdb 8 , 628c69a537cSWolfram Schneider.Xr vipw 8 629afe61c15SRodney W. Grimes.Sh BUGS 630afe61c15SRodney W. GrimesUser information should (and eventually will) be stored elsewhere. 631f274239bSGarrett Wollman.Pp 632f274239bSGarrett WollmanThe YP/NIS password database makes encrypted passwords visible to 633a755ea5bSBill Paulordinary users, thus making password cracking easier unless you use 634a755ea5bSBill Paulshadow passwords with the 635a755ea5bSBill Paul.Pa master.passwd 636dd5527c6SMike Pritchardmaps and 637dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 638a755ea5bSBill Paul.Xr ypserv 8 639a755ea5bSBill Paulserver. 640f274239bSGarrett Wollman.Pp 641dd5527c6SMike PritchardUnless you're using 642dd5527c6SMike Pritchard.Tn FreeBSD Ns 's 643a755ea5bSBill Paul.Xr ypserv 8 , 644a755ea5bSBill Paulwhich supports the use of 645a755ea5bSBill Paul.Pa master.passwd 6464a8d0283SMike Pritchardtype maps, 647a755ea5bSBill Paulthe YP/NIS password database will be in old-style (Sixth Edition) format, 648a755ea5bSBill Paulwhich means that site-wide values for user login class, password 649a755ea5bSBill Paulexpiration date, and other fields present in the current format 650dd5527c6SMike Pritchardwill not be available when a 651dd5527c6SMike Pritchard.Tn FreeBSD 652dd5527c6SMike Pritchardsystem is used as a client with 653a755ea5bSBill Paula standard NIS server. 654afe61c15SRodney W. Grimes.Sh COMPATIBILITY 65521421932SMike PritchardThe password file format has changed since 65621421932SMike Pritchard.Bx 4.3 . 657afe61c15SRodney W. GrimesThe following awk script can be used to convert your old-style password 658afe61c15SRodney W. Grimesfile into a new style password file. 659afe61c15SRodney W. GrimesThe additional fields 660afe61c15SRodney W. Grimes.Dq class , 661afe61c15SRodney W. Grimes.Dq change 662afe61c15SRodney W. Grimesand 663afe61c15SRodney W. Grimes.Dq expire 664afe61c15SRodney W. Grimesare added, but are turned off by default. 665afe61c15SRodney W. GrimesClass is currently not implemented, but change and expire are; to set them, 666afe61c15SRodney W. Grimesuse the current day in seconds from the epoch + whatever number of seconds 667afe61c15SRodney W. Grimesof offset you want. 668afe61c15SRodney W. Grimes.Bd -literal -offset indent 669afe61c15SRodney W. GrimesBEGIN { FS = ":"} 670afe61c15SRodney W. Grimes{ print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 } 671afe61c15SRodney W. Grimes.Ed 672afe61c15SRodney W. Grimes.Sh HISTORY 673afe61c15SRodney W. GrimesA 674afe61c15SRodney W. Grimes.Nm 675afe61c15SRodney W. Grimesfile format appeared in 676afe61c15SRodney W. Grimes.At v6 . 677f274239bSGarrett WollmanThe YP/NIS functionality is modeled after 678f274239bSGarrett Wollman.Tn SunOS 679f274239bSGarrett Wollmanand first appeared in 680dd5527c6SMike Pritchard.Fx 1.1 681dd5527c6SMike PritchardThe override capability is new in 68246f84fcbSMike Pritchard.Fx 2.0 . 68346f84fcbSMike PritchardThe override capability was updated to properly support netgroups 684a755ea5bSBill Paulin 68546f84fcbSMike Pritchard.Fx 2.0.5 . 686f57cc79dSMike PritchardSupport for comments first appeared in 68722bf9812SWolfram Schneider.Fx 3.0 . 688