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 331130b656SJordan K. Hubbard.\" $FreeBSD$ 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 73afe61c15SRodney W. GrimesThe 74afe61c15SRodney W. Grimes.Ar name 75afe61c15SRodney W. Grimesfield is the login used to access the computer account, and the 76afe61c15SRodney W. Grimes.Ar uid 77afe61c15SRodney W. Grimesfield is the number associated with it. They should both be unique 78afe61c15SRodney W. Grimesacross the system (and often across a group of systems) since they 79afe61c15SRodney W. Grimescontrol file access. 80afe61c15SRodney W. Grimes.Pp 81afe61c15SRodney W. GrimesWhile it is possible to have multiple entries with identical login names 82afe61c15SRodney W. Grimesand/or identical user id's, it is usually a mistake to do so. Routines 83afe61c15SRodney W. Grimesthat manipulate these files will often return only one of the multiple 84afe61c15SRodney W. Grimesentries, and that one by random selection. 85afe61c15SRodney W. Grimes.Pp 86afe61c15SRodney W. GrimesThe login name must never begin with a hyphen (``-''); also, it is strongly 87afe61c15SRodney W. Grimessuggested that neither upper-case characters or dots (``.'') be part 88afe61c15SRodney W. Grimesof the name, as this tends to confuse mailers. No field may contain a 89afe61c15SRodney W. Grimescolon (``:'') as this has been used historically to separate the fields 90afe61c15SRodney W. Grimesin the user database. 91afe61c15SRodney W. Grimes.Pp 92afe61c15SRodney W. GrimesThe password field is the 93afe61c15SRodney W. Grimes.Em encrypted 94afe61c15SRodney W. Grimesform of the password. 95afe61c15SRodney W. GrimesIf the 96afe61c15SRodney W. Grimes.Ar password 97afe61c15SRodney W. Grimesfield is empty, no password will be required to gain access to the 98afe61c15SRodney W. Grimesmachine. This is almost invariably a mistake. 99afe61c15SRodney W. GrimesBecause these files contain the encrypted user passwords, they should 100afe61c15SRodney W. Grimesnot be readable by anyone without appropriate privileges. 101408bc30dSDavid NugentAdministrative accounts have a password field containing an asterisk 102408bc30dSDavid Nugent.Ql \&* 103408bc30dSDavid Nugentwhich disallows normal logins. 104afe61c15SRodney W. Grimes.Pp 105afe61c15SRodney W. GrimesThe group field is the group that the user will be placed in upon login. 106408bc30dSDavid NugentAlthough this system supports multiple groups (see 107afe61c15SRodney W. Grimes.Xr groups 1 ) 108408bc30dSDavid Nugentthis field nominates the user's primary groups. 109408bc30dSDavid NugentSecondary group memberships are selected in 110408bc30dSDavid Nugent.Pa /etc/group . 111afe61c15SRodney W. Grimes.Pp 112afe61c15SRodney W. GrimesThe 113afe61c15SRodney W. Grimes.Ar class 114408bc30dSDavid Nugentfield is a key for a user's login class. 115408bc30dSDavid NugentLogin classes are defined in 116408bc30dSDavid Nugent.Xr login.conf 5 , 117408bc30dSDavid Nugentwhich is a 118afe61c15SRodney W. Grimes.Xr termcap 5 119408bc30dSDavid Nugentstyle database of user attributes, accounting, resource and 120408bc30dSDavid Nugentenvironment settings. 121afe61c15SRodney W. Grimes.Pp 122afe61c15SRodney W. GrimesThe 123afe61c15SRodney W. Grimes.Ar change 124afe61c15SRodney W. Grimesfield is the number in seconds, 125afe61c15SRodney W. Grimes.Dv GMT , 126afe61c15SRodney W. Grimesfrom the epoch, until the 127afe61c15SRodney W. Grimespassword for the account must be changed. 128408bc30dSDavid NugentThis field may be left empty or set to 0 to turn off the 129408bc30dSDavid Nugentpassword aging feature. 130afe61c15SRodney W. Grimes.Pp 131afe61c15SRodney W. GrimesThe 132afe61c15SRodney W. Grimes.Ar expire 133afe61c15SRodney W. Grimesfield is the number in seconds, 134afe61c15SRodney W. Grimes.Dv GMT , 135afe61c15SRodney W. Grimesfrom the epoch, until the 136afe61c15SRodney W. Grimesaccount expires. 137408bc30dSDavid NugentThis field may be left empty or set to 0 to turn off the account 138408bc30dSDavid Nugentaging feature. 139afe61c15SRodney W. Grimes.Pp 140afe61c15SRodney W. GrimesThe 141afe61c15SRodney W. Grimes.Ar gecos 142afe61c15SRodney W. Grimesfield normally contains comma (``,'') separated subfields as follows: 143afe61c15SRodney W. Grimes.Pp 144afe61c15SRodney W. Grimes.Bd -unfilled -offset indent 145408bc30dSDavid Nugentfullname user's full name 146afe61c15SRodney W. Grimesoffice user's office number 147afe61c15SRodney W. Grimeswphone user's work phone number 148afe61c15SRodney W. Grimeshphone user's home phone number 149afe61c15SRodney W. Grimes.Ed 150afe61c15SRodney W. Grimes.Pp 151afe61c15SRodney W. GrimesThis information is used by the 152afe61c15SRodney W. Grimes.Xr finger 1 153408bc30dSDavid Nugentprogram, and the first field used by the system mailer. 154408bc30dSDavid NugentIf an ampersand 155408bc30dSDavid Nugent.Ql \&& 156408bc30dSDavid Nugentcharacter appears within the fullname field, programs which 157408bc30dSDavid Nugentuse this field will substitute it with a capitalized version 158408bc30dSDavid Nugentof the account's login name. 159afe61c15SRodney W. Grimes.Pp 160afe61c15SRodney W. GrimesThe user's home directory is the full 161afe61c15SRodney W. Grimes.Tn UNIX 162afe61c15SRodney W. Grimespath name where the user 163afe61c15SRodney W. Grimeswill be placed on login. 164afe61c15SRodney W. Grimes.Pp 165afe61c15SRodney W. GrimesThe shell field is the command interpreter the user prefers. 166afe61c15SRodney W. GrimesIf there is nothing in the 167afe61c15SRodney W. Grimes.Ar shell 168afe61c15SRodney W. Grimesfield, the Bourne shell 169afe61c15SRodney W. Grimes.Pq Pa /bin/sh 170afe61c15SRodney W. Grimesis assumed. 171f274239bSGarrett Wollman.Sh YP/NIS INTERACTION 172a755ea5bSBill Paul.Ss Enabling access to NIS passwd data 173a755ea5bSBill PaulThe system administrator can configure FreeBSD to use NIS/YP for 174a755ea5bSBill Paulits password information by adding special records to the 175f274239bSGarrett Wollman.Pa /etc/master.passwd 176a755ea5bSBill Paulfile. These entries should be added with 177a755ea5bSBill Paul.Xr vipw 8 178a755ea5bSBill Paulso that the changes can be properly merged with the hashed 179a755ea5bSBill Paulpassword databases and the 180a755ea5bSBill Paul.Pa /etc/passwd 181a755ea5bSBill Paulfile ( 182a755ea5bSBill Paul.Pa /etc/passwd 183a755ea5bSBill Paulshould never be edited manually). Alternatively, the administrator 184a755ea5bSBill Paulcan modify 185a755ea5bSBill Paul.Pa /etc/master.passwd 186a755ea5bSBill Paulin some other way and then manually update the password databases with 187a755ea5bSBill Paul.Xr pwd_mkdb 8 . 188a755ea5bSBill Paul.Pp 189a755ea5bSBill PaulThe simplest way to activate NIS is to add an empty record 190a755ea5bSBill Paulwith only a plus sign (`+') in the name field, such as this: 191f274239bSGarrett Wollman.Bd -literal -offset indent 192a755ea5bSBill Paul+::::::::: 193f274239bSGarrett Wollman 194f274239bSGarrett Wollman.Ed 195a755ea5bSBill PaulThe `+' will tell the 196a755ea5bSBill Paul.Xr getpwent 3 197a755ea5bSBill Paulroutines in FreeBSD's standard C library to begin using the NIS passwd maps 198a755ea5bSBill Paulfor lookups. 199f274239bSGarrett Wollman.Pp 200a755ea5bSBill PaulNote that the entry shown above is known as a 201a755ea5bSBill Paul.Pa wildcard 202a755ea5bSBill Paulentry, because it matches all users (the `+' without any other information 203a755ea5bSBill Paulmatches everybody) and allows all NIS password data to be retrieved 204a755ea5bSBill Paulunaltered. However, by 205a755ea5bSBill Paulspecifying a username or netgroup next to the `+' in the NIS 206a755ea5bSBill Paulentry, the administrator can affect what data is extracted from the 207a755ea5bSBill PaulNIS passwd maps and how it is interpreted. Here are a few example 208a755ea5bSBill Paulrecords that illustrate this feature (note that you can have several 209a755ea5bSBill PaulNIS entries in a single 210a755ea5bSBill Paul.Pa master.passwd 211a755ea5bSBill Paulfile): 212a755ea5bSBill Paul.Bd -literal -offset indent 213a755ea5bSBill Paul-mitnick::::::::: 214a755ea5bSBill Paul+@staff::::::::: 215a755ea5bSBill Paul+@permitted-users::::::::: 216a755ea5bSBill Paul+dennis::::::::: 217a755ea5bSBill Paul+ken:::::::::/bin/csh 218a755ea5bSBill Paul+@rejected-users::32767:32767::::::/bin/false 219a755ea5bSBill Paul 220a755ea5bSBill Paul.Ed 221a755ea5bSBill PaulSpecific usernames are listed explicitly while netgroups are signfied 2224a8d0283SMike Pritchardby a preceding `@'. In the above example, users in the ``staff'' and 223a755ea5bSBill Paul``permitted-users'' netgroups will have their password information 2244a8d0283SMike Pritchardread from NIS and used unaltered. In other words, they will be allowed 225a755ea5bSBill Paulnormal access to the machine. Users ``ken'' and ``dennis,'' who have 2264a8d0283SMike Pritchardbeen named explicitly rather than through a netgroup, will also have 227a755ea5bSBill Paultheir password data read from NIS, _except_ that user ``ken'' will 228a755ea5bSBill Paulhave his shell remapped to 229a755ea5bSBill Paul.Pa /bin/csh . 230a755ea5bSBill PaulThis means that value for his shell specified in the NIS password map 2314a8d0283SMike Pritchardwill be overridden by the value specified in the special NIS entry in 232a755ea5bSBill Paulthe local 233a755ea5bSBill Paul.Pa master.passwd 234a755ea5bSBill Paulfile. User ``ken'' may have been assigned the csh shell because his 235a755ea5bSBill PaulNIS password entry specified a different shell that may not be 236a755ea5bSBill Paulinstalled on the client machine for political or technical reasons. 237a755ea5bSBill PaulMeanwhile, users in the ``rejected-users'' netgroup are prevented 238a755ea5bSBill Paulfrom logging in because their UIDs, GIDs and shells have been overridden 239a755ea5bSBill Paulwith invalid values. 240a755ea5bSBill Paul.Pp 241a755ea5bSBill PaulUser ``mitnick'' will be be ignored entirely because his entry is 242a755ea5bSBill Paulspecified with a `-' instead of a `+'. A minus entry can be used 243a755ea5bSBill Paulto block out certain NIS password entries completely; users who's 244a755ea5bSBill Paulpassword data has been excluded in this way are not recognized by 245a755ea5bSBill Paulthe system at all. (Any overrides specified with minus entries are 246a755ea5bSBill Paulalso ignored since there is no point in processing override information 247a755ea5bSBill Paulfor a user that the system isn't going to recognize in the first place.) 248a755ea5bSBill PaulIn general, a minus entry is used to specifically exclude a user 249a755ea5bSBill Paulwho might otherwise be granted access because he happens to be a 250a755ea5bSBill Paulmember of an authorized netgroup. For example, if ``mitnick'' is 251a755ea5bSBill Paula member of the ``permitted-users'' netgroup and must, for whatever 252a755ea5bSBill Paulthe reason, be permitted to remain in that netgroup (possibly to 2534a8d0283SMike Pritchardretain access to other machines within the domain), the administrator 254a755ea5bSBill Paulcan still deny him access to a particular system with a minus entry. 255a755ea5bSBill PaulAlso, it is sometimes easier to explicitly list those users who aren't 256a755ea5bSBill Paulallowed access rather than generate a possibly complicated list of 257a755ea5bSBill Paulusers who are allowed access and omit the rest. 258a755ea5bSBill Paul.Pp 259a755ea5bSBill PaulNote that the plus and minus entries are evaluated in order from 260a755ea5bSBill Paulfirst to last with the first match taking precedence. This means 261a755ea5bSBill Paulthat the system will only use the first entry which matches a particular user. 262a755ea5bSBill PaulIf, for instance, we have a user ``foo'' who is a member of both the ``staff'' 263a755ea5bSBill Paulnetgroup and the ``rejected-users'' netgroup, he will be admitted to 264a755ea5bSBill Paulthe system because the above example lists the entry for ``staff'' 265a755ea5bSBill Paulbefore the entry for ``rejected-users.'' If we reversed the order, 266a755ea5bSBill Pauluser ``foo'' would be flagged as a ``rejected-user'' instead and 267a755ea5bSBill Pauldenied access. 268a755ea5bSBill Paul.Pp 269a755ea5bSBill PaulLastly, any NIS password database records that do not match against 270a755ea5bSBill Paulat least one of the users or netgroups specified by the NIS access 271a755ea5bSBill Paulentries in the 272a755ea5bSBill Paul.Pa /etc/master.passwd 273a755ea5bSBill Paulfile will be ignored (along with any users specified using minus 274a755ea5bSBill Paulentries). In our example shown above, we do not have a wildcard 275a755ea5bSBill Paulentry at the end of the list; therefore, the system will not recognize 276a755ea5bSBill Paulanyone except 277a755ea5bSBill Paul``ken,'' ``dennis,'' the ``staff'' netgroup and the ``permitted-users'' 278a755ea5bSBill Paulnetgroup as authorized users. The ``rejected-users'' netgroup will 279a755ea5bSBill Paulbe recognized but all members will have their shells remapped and 280a755ea5bSBill Paultherefore be denied access. 281a755ea5bSBill PaulAll other NIS password records 282a755ea5bSBill Paulwill be ignored. The administrator may add a wildcard entry to the 283a755ea5bSBill Paulend of the list such as: 284a755ea5bSBill Paul.Bd -literal -offset indent 285a755ea5bSBill Paul+:::::::::/usr/local/bin/go_away 286a755ea5bSBill Paul 287a755ea5bSBill Paul.Ed 288a755ea5bSBill PaulThis entry acts as a catch-all for all users that don't match against 289a755ea5bSBill Paulany of the other entries. 290a755ea5bSBill Paul.Pa /usr/local/bin/go_away 291a755ea5bSBill Paulcan be a short shell script or program 292a755ea5bSBill Paulthat prints a message telling the user that he is not allowed access 2934a8d0283SMike Pritchardto the system. This technique is sometimes useful when it is 2944a8d0283SMike Pritcharddesirable to have the system be able to recognize all users in a 295a755ea5bSBill Paulparticular NIS domain without necessarily granting them login access. 296a755ea5bSBill Paul.Pp 297a755ea5bSBill PaulThe primary use of this 298a755ea5bSBill Paul.Pa override 299a755ea5bSBill Paulfeature is to permit the administrator 300a755ea5bSBill Paulto enforce access restrictions on NIS client systems. Users can be 301a755ea5bSBill Paulgranted access to one group of machines and denied access to other 302a755ea5bSBill Paulmachines simply by adding or removing them from a particular netgroup. 303a755ea5bSBill PaulSince the netgroup database can also be accessed via NIS, this allows 304a755ea5bSBill Paulaccess restrictions to be administered from a single location, namely 305a755ea5bSBill Paulthe NIS master server; once a host's access list has been set in 306a755ea5bSBill Paul.Pa /etc/master.passwd , 307a755ea5bSBill Paulit need not be modified again unless new netgroups are created. 308a755ea5bSBill Paul.Sh NOTES 309a755ea5bSBill Paul.Ss Shadow passwords through NIS 310a755ea5bSBill PaulFreeBSD uses a shadow password scheme: users' encrypted passwords 311a755ea5bSBill Paulare stored only in 312a755ea5bSBill Paul.Pa /etc/master.passwd 313a755ea5bSBill Pauland 314a755ea5bSBill Paul.Pa /etc/spwd.db , 315a755ea5bSBill Paulwhich are readable and writable only by the superuser. This is done 316a755ea5bSBill Paulto prevent users from running the encrypted passwords through 317a755ea5bSBill Paulpassword-guessing programs and gaining unauthorized access to 318a755ea5bSBill Paulother users' accounts. NIS does not support a standard means of 319a755ea5bSBill Paulpassword shadowing, which implies that placing your password data 320a755ea5bSBill Paulinto the NIS passwd maps totally defeats the security of FreeBSD's 321a755ea5bSBill Paulpassword shadowing system. 322a755ea5bSBill Paul.Pp 323a755ea5bSBill PaulFreeBSD provides a few special features to help get around this 3244a8d0283SMike Pritchardproblem. It is possible to implement password shadowing between 325a755ea5bSBill PaulFreeBSD NIS clients and FreeBSD NIS servers. The 326a755ea5bSBill Paul.Xr getpwent 3 327a755ea5bSBill Paulroutines will search for a 328a755ea5bSBill Paul.Pa master.passwd.byname 329a755ea5bSBill Pauland 330a755ea5bSBill Paul.Pa master.passwd.byuid 331a755ea5bSBill Paulmaps which should contain the same data found in the 332a755ea5bSBill Paul.Pa /etc/master.passwd 333a755ea5bSBill Paulfile. If the maps exist, FreeBSD will attempt to use them for user 334a755ea5bSBill Paulauthentication instead of the standard 335a755ea5bSBill Paul.Pa passwd.byname 336a755ea5bSBill Pauland 337a755ea5bSBill Paul.Pa passwd.byuid 338a755ea5bSBill Paulmaps. FreeBSD's 339a755ea5bSBill Paul.Xr ypserv 8 340a755ea5bSBill Paulwill also check client requests to make sure they originate on a 341a755ea5bSBill Paulprivileged port. Since only the superuser is allowed to bind to 342a755ea5bSBill Paula privileged port, the server can tell if the requesting user 343a755ea5bSBill Paulis the superuser; all requests from non-privileged users to access 344a755ea5bSBill Paulthe 345a755ea5bSBill Paul.Pa master.passwd 346a755ea5bSBill Paulmaps will be refused. Since all user authentication programs run 347a755ea5bSBill Paulwith superuser privilege, they should have the required access to 348a755ea5bSBill Paulusers' encrypted password data while normal users will only 349a755ea5bSBill Paulbe allowed access to the standard 350a755ea5bSBill Paul.Pa passwd 351a755ea5bSBill Paulmaps which contain no password information. 352a755ea5bSBill Paul.Pp 353a755ea5bSBill PaulNote that this feature cannot be used in an environment with 354a755ea5bSBill Paulnon-FreeBSD systems. Note also that a truly determined user with 355a755ea5bSBill Paulunrestricted access to your network could still compromise the 356a755ea5bSBill Paul.Pa master.passwd 357a755ea5bSBill Paulmaps. 358a755ea5bSBill Paul.Ss UID and GID remapping with NIS overrides 359a755ea5bSBill PaulUnlike SunOS and other operating systems that use Sun's NIS code, 360a755ea5bSBill PaulFreeBSD allows the user to override 361a755ea5bSBill Paul.Pa all 362a755ea5bSBill Paulof the fields in a user's NIS 363a755ea5bSBill Paul.Pa passwd 364a755ea5bSBill Paulentry. 365a755ea5bSBill PaulFor example, consider the following 366a755ea5bSBill Paul.Pa /etc/master.passwd 367a755ea5bSBill Paulentry: 368a755ea5bSBill Paul.Bd -literal -offset indent 369a755ea5bSBill Paul+@foo-users:???:666:666:0:0:0:Bogus user:/home/bogus:/bin/bogus 370a755ea5bSBill Paul 371a755ea5bSBill Paul.Ed 372a755ea5bSBill PaulThis entry will cause all users in the `foo-users' netgroup to 373a755ea5bSBill Paulhave 374a755ea5bSBill Paul.Pa all 3754a8d0283SMike Pritchardof their password information overridden, including UIDs, 376a755ea5bSBill PaulGIDs and passwords. The result is that all `foo-users' will be 377a755ea5bSBill Paullocked out of the system, since their passwords will be remapped 378a755ea5bSBill Paulto invalid values. 379a755ea5bSBill Paul.Pp 380a755ea5bSBill PaulThis is important to remember because most people are accustomed to 381a755ea5bSBill Paulusing an NIS wildcard entry that looks like this: 382a755ea5bSBill Paul.Bd -literal -offset indent 383a755ea5bSBill Paul+:*:0:0::: 384a755ea5bSBill Paul 385a755ea5bSBill Paul.Ed 3864a8d0283SMike PritchardThis often leads to new FreeBSD administrators choosing NIS entries for their 387a755ea5bSBill Paul.Pa master.passwd 388a755ea5bSBill Paulfiles that look like this: 389a755ea5bSBill Paul.Bd -literal -offset indent 390a755ea5bSBill Paul+:*:0:0:::::: 391a755ea5bSBill Paul 392a755ea5bSBill Paul.Ed 393a755ea5bSBill PaulOr worse, this 394a755ea5bSBill Paul.Bd -literal -offset indent 395a755ea5bSBill Paul+::0:0:::::: 396a755ea5bSBill Paul 397a755ea5bSBill Paul.Ed 398a755ea5bSBill Paul.Pa DO _NOT_ PUT ENTRIES LIKE THIS IN YOUR 399a755ea5bSBill Paul.Nm master.passwd 400a755ea5bSBill Paul.Pa FILE!! 401a755ea5bSBill PaulThe first tells FreeBSD to remap all passwords to `*' (which 402a755ea5bSBill Paulwill prevent anybody from logging in) and to remap all UIDs and GIDs 403a755ea5bSBill Paulto 0 (which will make everybody appear to be the superuser). The 404a755ea5bSBill Paulsecond case just maps all UIDs and GIDs to 0, which means that 405a755ea5bSBill Paul.Pa all users will appear to be root! 406a755ea5bSBill Paul.Pp 407a755ea5bSBill Paul.Ss Compatibility of NIS override evaluation 408a755ea5bSBill PaulWhen Sun originally added NIS support to their 409a755ea5bSBill Paul.Xr getpwent 3 410a755ea5bSBill Paulroutines, they took into account the fact that the SunOS password 411a755ea5bSBill Paul.Pa /etc/passwd 412a755ea5bSBill Paulfile is in plain ASCII format. The SunOS documentation claims that 413a755ea5bSBill Pauladding a '+' entry to the password file causes the contents of 414a755ea5bSBill Paulthe NIS password database to be 'inserted' at the position in 415a755ea5bSBill Paulthe file where the '+' entry appears. If, for example, the 416a755ea5bSBill Pauladministrator places the +:::::: entry in the middle of 417a755ea5bSBill Paul.Pa /etc/passwd, 418a755ea5bSBill Paulthen the entire contents of the NIS password map would appear 419a755ea5bSBill Paulas though it had been copied into the middle of the password 420a755ea5bSBill Paulfile. If the administrator places the +:::::: entry at both the 421a755ea5bSBill Paulmiddle and the end of 422a755ea5bSBill Paul.Pa /etc/passwd , 423a755ea5bSBill Paulthen the NIS password map would appear twice: once in the middle 424a755ea5bSBill Paulof the file and once at the end. (By using override entries 425a755ea5bSBill Paulinstead of simple wildcards, other combinations could be achieved.) 426a755ea5bSBill Paul.Pp 427a755ea5bSBill PaulBy contrast, FreeBSD does not have a single ASCII password file: it 428a755ea5bSBill Paulhas a hashed password database. This database does not have an 429a755ea5bSBill Pauleasily-defined beginning, middle or end, which makes it very hard 430a755ea5bSBill Paulto design a scheme that is 100% compatible with SunOS. For example, 431a755ea5bSBill Paulthe 432a755ea5bSBill Paul.Fn getpwnam 433a755ea5bSBill Pauland 434f274239bSGarrett Wollman.Fn getpwuid 435a755ea5bSBill Paulfunctions in FreeBSD are designed to do direct queries to the 436a755ea5bSBill Paulhash database rather than a linear search. This approach is faster 437a755ea5bSBill Paulon systems where the password database is large. However, when 438a755ea5bSBill Paulusing direct database queries, the system does not know or care 439a755ea5bSBill Paulabout the order of the original password file, and therefore 440a755ea5bSBill Paulit cannot easily apply the same override logic used by SunOS. 441a755ea5bSBill Paul.Pp 442a755ea5bSBill PaulInstead, FreeBSD groups all the NIS override entries together 443a755ea5bSBill Pauland constructs a filter out of them. Each NIS password entry 444a755ea5bSBill Paulis compared against the override filter exactly once and 445a755ea5bSBill Paultreated accordingly: if the filter allows the entry through 446a755ea5bSBill Paulunaltered, it's treated unaltered; if the filter calls for remapping 447a755ea5bSBill Paulof fields, then fields are remapped; if the filter calls for 448a755ea5bSBill Paulexplicit exclusion (i.e. the entry matches a '-' override), 449a755ea5bSBill Paulthe entry is ignored; if the entry doesn't match against any 450a755ea5bSBill Paulof the filter specifications, it's discarded. 451a755ea5bSBill Paul.Pp 452a755ea5bSBill PaulAgain, note that the NIS '+' and '-' entries 453a755ea5bSBill Paulthemselves are handled in the order in which they were specified 454a755ea5bSBill Paulin the 455a755ea5bSBill Paul.Pa /etc/master.passwd 456a755ea5bSBill Paulfile since doing otherwise would lead to unpredicable behavior. 457a755ea5bSBill Paul.Pp 458a755ea5bSBill PaulThe end result is that FreeBSD's provides a very close approximation 459a755ea5bSBill Paulof SunOS's behavior while maintaining the database paradigm, though the 460a755ea5bSBill Paul.Xr getpwent 3 461a755ea5bSBill Paulfunctions do behave somewhat differently that their SunOS counterparts. 462a755ea5bSBill PaulThe primary differences are: 463a755ea5bSBill Paul.Bl -bullet -offset indent 464a755ea5bSBill Paul.It 465a755ea5bSBill PaulEach NIS password map record can be mapped into the password 466a755ea5bSBill Paullocal password space only once. 467a755ea5bSBill Paul.It 468a755ea5bSBill PaulThe placement of the NIS '+' and '-' entries does not necessarily 469a755ea5bSBill Paulaffect where NIS password records will be mapped into 470a755ea5bSBill Paulthe password space. 471a755ea5bSBill Paul.El 472a755ea5bSBill Paul.Pp 473a755ea5bSBill PaulIn %99 of all FreeBSD configurations, NIS client behavior will be 474a755ea5bSBill Paulindistinguishable from that of SunOS or other similar systems. Even 4754a8d0283SMike Pritchardso, users should be aware of these architectural differences. 476a755ea5bSBill Paul.Pp 477a755ea5bSBill Paul.Ss Using groups instead of netgroups for NIS overrides 478a755ea5bSBill PaulFreeBSD offers the capability to do override matching based on 479a755ea5bSBill Pauluser groups rather than netgroups. If, for example, an NIS entry 480a755ea5bSBill Paulis specified as: 481a755ea5bSBill Paul.Bd -literal -offset indent 482a755ea5bSBill Paul+@operator::::::::: 483a755ea5bSBill Paul 484a755ea5bSBill Paul.Ed 485a755ea5bSBill Paulthe system will first try to match users against a netgroup called 486a755ea5bSBill Paul`operator.' If an `operator' netgroup doesn't exist, the system 487a755ea5bSBill Paulwill try to match users against the normal `operator' group 488a755ea5bSBill Paulinstead. 489a755ea5bSBill Paul.Ss Changes in behavior from older versions of FreeBSD 490a755ea5bSBill PaulThere have been several bug fixes and improvements in FreeBSD's 491a755ea5bSBill PaulNIS/YP handling, some of which have caused changes in behavior. 492a755ea5bSBill PaulWhile the behavior changes are generally positive, it is important 493a755ea5bSBill Paulthat users and system administrators be aware of them: 494a755ea5bSBill Paul.Bl -enum -offset indent 495a755ea5bSBill Paul.It 496a755ea5bSBill PaulIn versions prior to 2.0.5, reverse lookups (i.e. using 497a755ea5bSBill Paul.Fn getpwuid ) 498a755ea5bSBill Paulwould not have overrides applied, which is to say that it 499a755ea5bSBill Paulwas possible for 500a755ea5bSBill Paul.Fn getpwuid 501a755ea5bSBill Paulto return a login name that 502a755ea5bSBill Paul.Fn getpwnam 503a755ea5bSBill Paulwould not recognize. This has been fixed: overrides specified 504a755ea5bSBill Paulin 505a755ea5bSBill Paul.Pa /etc/master.passwd 506a755ea5bSBill Paulnow apply to all 507a755ea5bSBill Paul.Xr getpwent 3 508a755ea5bSBill Paulfunctions. 509a755ea5bSBill Paul.It 510a755ea5bSBill PaulPrior to FreeBSD 2.0.5, netgroup overrides did not work at 511a755ea5bSBill Paulall, largely because FreeBSD did not have support for reading 512a755ea5bSBill Paulnetgroups through NIS. Again, this has been fixed, and 513a755ea5bSBill Paulnetgroups can be specified just as in SunOS and similar NIS-capable 514a755ea5bSBill Paulsystems. 515a755ea5bSBill Paul.It 516a755ea5bSBill PaulFreeBSD now has NIS server capabilities and supports the use 517a755ea5bSBill Paulof 518a755ea5bSBill Paul.Pa master.passwd 519a755ea5bSBill PaulNIS maps in addition to the standard Sixth Edition format 520a755ea5bSBill Paul.Pa passwd 521a755ea5bSBill Paulmaps. 522a755ea5bSBill PaulThis means that you can specify change, expiration and class 523a755ea5bSBill Paulinformation through NIS, provided you use a FreeBSD system as 524a755ea5bSBill Paulthe NIS server. 525a755ea5bSBill Paul.El 526f274239bSGarrett Wollman.Sh FILES 527f274239bSGarrett Wollman.Bl -tag -width /etc/master.passwd -compact 528f274239bSGarrett Wollman.It Pa /etc/passwd 529f274239bSGarrett WollmanASCII password file, with passwords removed 530f274239bSGarrett Wollman.It Pa /etc/pwd.db 531f274239bSGarrett Wollman.Xr db 3 -format 532f274239bSGarrett Wollmanpassword database, with passwords removed 533f274239bSGarrett Wollman.It Pa /etc/master.passwd 534f274239bSGarrett WollmanASCII password file, with passwords intact 535f274239bSGarrett Wollman.It Pa /etc/spwd.db 536f274239bSGarrett Wollman.Xr db 3 -format 537f274239bSGarrett Wollmanpassword database, with passwords intact 538f274239bSGarrett Wollman.El 539afe61c15SRodney W. Grimes.Sh SEE ALSO 540afe61c15SRodney W. Grimes.Xr chpass 1 , 541afe61c15SRodney W. Grimes.Xr login 1 , 542afe61c15SRodney W. Grimes.Xr passwd 1 , 543c69a537cSWolfram Schneider.Xr getpwent 3 , 544408bc30dSDavid Nugent.Xr login_getclass 3 , 545c69a537cSWolfram Schneider.Xr yp 4 , 546408bc30dSDavid Nugent.Xr login.conf 5 , 547c69a537cSWolfram Schneider.Xr adduser 8 , 548afe61c15SRodney W. Grimes.Xr pwd_mkdb 8 , 549c69a537cSWolfram Schneider.Xr vipw 8 550afe61c15SRodney W. Grimes.Sh BUGS 551afe61c15SRodney W. GrimesUser information should (and eventually will) be stored elsewhere. 552f274239bSGarrett Wollman.Pp 553f274239bSGarrett WollmanThe YP/NIS password database makes encrypted passwords visible to 554a755ea5bSBill Paulordinary users, thus making password cracking easier unless you use 555a755ea5bSBill Paulshadow passwords with the 556a755ea5bSBill Paul.Pa master.passwd 557a755ea5bSBill Paulmaps and FreeBSD's 558a755ea5bSBill Paul.Xr ypserv 8 559a755ea5bSBill Paulserver. 560f274239bSGarrett Wollman.Pp 561a755ea5bSBill PaulUnless you're using FreeBSD's 562a755ea5bSBill Paul.Xr ypserv 8 , 563a755ea5bSBill Paulwhich supports the use of 564a755ea5bSBill Paul.Pa master.passwd 5654a8d0283SMike Pritchardtype maps, 566a755ea5bSBill Paulthe YP/NIS password database will be in old-style (Sixth Edition) format, 567a755ea5bSBill Paulwhich means that site-wide values for user login class, password 568a755ea5bSBill Paulexpiration date, and other fields present in the current format 569a755ea5bSBill Paulwill not be available when a FreeBSD system is used as a client with 570a755ea5bSBill Paula standard NIS server. 571afe61c15SRodney W. Grimes.Sh COMPATIBILITY 57221421932SMike PritchardThe password file format has changed since 57321421932SMike Pritchard.Bx 4.3 . 574afe61c15SRodney W. GrimesThe following awk script can be used to convert your old-style password 575afe61c15SRodney W. Grimesfile into a new style password file. 576afe61c15SRodney W. GrimesThe additional fields 577afe61c15SRodney W. Grimes.Dq class , 578afe61c15SRodney W. Grimes.Dq change 579afe61c15SRodney W. Grimesand 580afe61c15SRodney W. Grimes.Dq expire 581afe61c15SRodney W. Grimesare added, but are turned off by default. 582afe61c15SRodney W. GrimesClass is currently not implemented, but change and expire are; to set them, 583afe61c15SRodney W. Grimesuse the current day in seconds from the epoch + whatever number of seconds 584afe61c15SRodney W. Grimesof offset you want. 585afe61c15SRodney W. Grimes.Bd -literal -offset indent 586afe61c15SRodney W. GrimesBEGIN { FS = ":"} 587afe61c15SRodney W. Grimes{ print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 } 588afe61c15SRodney W. Grimes.Ed 589afe61c15SRodney W. Grimes.Sh HISTORY 590afe61c15SRodney W. GrimesA 591afe61c15SRodney W. Grimes.Nm 592afe61c15SRodney W. Grimesfile format appeared in 593afe61c15SRodney W. Grimes.At v6 . 594f274239bSGarrett WollmanThe YP/NIS functionality is modeled after 595f274239bSGarrett Wollman.Tn SunOS 596f274239bSGarrett Wollmanand first appeared in 597f274239bSGarrett Wollman.Tn FreeBSD 598f274239bSGarrett Wollman1.1. The override capability is new in 59946f84fcbSMike Pritchard.Fx 2.0 . 60046f84fcbSMike PritchardThe override capability was updated to properly support netgroups 601a755ea5bSBill Paulin 60246f84fcbSMike Pritchard.Fx 2.0.5 . 603