1248aee62SJacques Vidrine.\" $NetBSD: nsswitch.conf.5,v 1.14 1999/03/17 20:19:47 garbled Exp $ 2248aee62SJacques Vidrine.\" 3248aee62SJacques Vidrine.\" Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. 4248aee62SJacques Vidrine.\" All rights reserved. 5248aee62SJacques Vidrine.\" 6248aee62SJacques Vidrine.\" This code is derived from software contributed to The NetBSD Foundation 7248aee62SJacques Vidrine.\" by Luke Mewburn. 8248aee62SJacques Vidrine.\" 9248aee62SJacques Vidrine.\" Redistribution and use in source and binary forms, with or without 10248aee62SJacques Vidrine.\" modification, are permitted provided that the following conditions 11248aee62SJacques Vidrine.\" are met: 12248aee62SJacques Vidrine.\" 1. Redistributions of source code must retain the above copyright 13248aee62SJacques Vidrine.\" notice, this list of conditions and the following disclaimer. 14248aee62SJacques Vidrine.\" 2. Redistributions in binary form must reproduce the above copyright 15248aee62SJacques Vidrine.\" notice, this list of conditions and the following disclaimer in the 16248aee62SJacques Vidrine.\" documentation and/or other materials provided with the distribution. 17248aee62SJacques Vidrine.\" 3. All advertising materials mentioning features or use of this software 18248aee62SJacques Vidrine.\" must display the following acknowledgement: 19248aee62SJacques Vidrine.\" This product includes software developed by Luke Mewburn. 20248aee62SJacques Vidrine.\" 4. The name of the author may not be used to endorse or promote products 21248aee62SJacques Vidrine.\" derived from this software without specific prior written permission. 22248aee62SJacques Vidrine.\" 23248aee62SJacques Vidrine.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24248aee62SJacques Vidrine.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25248aee62SJacques Vidrine.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26248aee62SJacques Vidrine.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27248aee62SJacques Vidrine.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28248aee62SJacques Vidrine.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 29248aee62SJacques Vidrine.\" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30248aee62SJacques Vidrine.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 31248aee62SJacques Vidrine.\" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 32248aee62SJacques Vidrine.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33248aee62SJacques Vidrine.\" 3404bd07fdSAlan Somers.Dd September 6, 2020 35248aee62SJacques Vidrine.Dt NSSWITCH.CONF 5 36248aee62SJacques Vidrine.Os 37248aee62SJacques Vidrine.Sh NAME 38248aee62SJacques Vidrine.Nm nsswitch.conf 39248aee62SJacques Vidrine.Nd name-service switch configuration file 40248aee62SJacques Vidrine.Sh DESCRIPTION 41248aee62SJacques VidrineThe 42248aee62SJacques Vidrine.Nm 43248aee62SJacques Vidrinefile specifies how the 44248aee62SJacques Vidrine.Xr nsdispatch 3 45248aee62SJacques Vidrine(name-service switch dispatcher) routines in the C library should operate. 46248aee62SJacques Vidrine.Pp 47248aee62SJacques VidrineThe configuration file controls how a process looks up various databases 48248aee62SJacques Vidrinecontaining information regarding hosts, users (passwords), groups, etc. 49*5e20b96cSAlan SomersEach database comes from a source (such as local files, DNS, NIS , 50a8cceff8SHajimu UMEMOTOand cache), and the order to look up the sources is specified in 514b66483fSRuslan Ermilov.Nm . 52248aee62SJacques Vidrine.Pp 53248aee62SJacques VidrineEach entry in 54248aee62SJacques Vidrine.Nm 55248aee62SJacques Vidrineconsists of a database name, and a space separated list of sources. 56248aee62SJacques VidrineEach source can have an optional trailing criterion that determines 57248aee62SJacques Vidrinewhether the next listed source is used, or the search terminates at 58248aee62SJacques Vidrinethe current source. 59248aee62SJacques VidrineEach criterion consists of one or more status codes, and actions to 60248aee62SJacques Vidrinetake if that status code occurs. 61248aee62SJacques Vidrine.Ss Sources 62eabc4a4bSEdward Tomasz NapieralaThe following sources are implemented as part of the base system: 63d0353b83SRuslan Ermilov.Pp 64d0353b83SRuslan Ermilov.Bl -tag -width Source -compact 65d0353b83SRuslan Ermilov.It Sy Source 66d0353b83SRuslan Ermilov.Sy Description 67d0353b83SRuslan Ermilov.It files 68d0353b83SRuslan ErmilovLocal files, such as 69248aee62SJacques Vidrine.Pa /etc/hosts , 70248aee62SJacques Vidrineand 71248aee62SJacques Vidrine.Pa /etc/passwd . 72e622b479SHajimu UMEMOTO.It db 73e622b479SHajimu UMEMOTOLocal database. 74d0353b83SRuslan Ermilov.It dns 75d0353b83SRuslan ErmilovInternet Domain Name System. 76248aee62SJacques Vidrine.Dq hosts 77248aee62SJacques Vidrineand 78248aee62SJacques Vidrine.Sq networks 79248aee62SJacques Vidrineuse 80248aee62SJacques Vidrine.Sy IN 81248aee62SJacques Vidrineclass entries, all other databases use 82248aee62SJacques Vidrine.Sy HS 83248aee62SJacques Vidrineclass (Hesiod) entries. 84d0353b83SRuslan Ermilov.It nis 85d0353b83SRuslan ErmilovNIS (formerly YP) 86d0353b83SRuslan Ermilov.It compat 87d0353b83SRuslan Ermilovsupport 88248aee62SJacques Vidrine.Sq +/- 89248aee62SJacques Vidrinein the 90248aee62SJacques Vidrine.Dq passwd 91248aee62SJacques Vidrineand 92248aee62SJacques Vidrine.Dq group 93248aee62SJacques Vidrinedatabases. 94248aee62SJacques VidrineIf this is present, it must be the only source for that entry. 95a8cceff8SHajimu UMEMOTO.It cache 96a8cceff8SHajimu UMEMOTOmakes use of the 9744726a59SMichael Bushkov.Xr nscd 8 98a8cceff8SHajimu UMEMOTOdaemon. 99248aee62SJacques Vidrine.El 100eabc4a4bSEdward Tomasz Napierala.Pp 101eabc4a4bSEdward Tomasz NapieralaAdditional sources might be provided by third party software. 102248aee62SJacques Vidrine.Ss Databases 103248aee62SJacques VidrineThe following databases are used by the following C library functions: 104d0353b83SRuslan Ermilov.Pp 105d0353b83SRuslan Ermilov.Bl -tag -width networks -compact 106d0353b83SRuslan Ermilov.It Sy Database 107d0353b83SRuslan Ermilov.Sy "Used by" 108d0353b83SRuslan Ermilov.It group 10950c317acSBruce M Simpson.Xr getgrent 3 , 11050c317acSBruce M Simpson.Xr getgrent_r 3 , 11150c317acSBruce M Simpson.Xr getgrgid_r 3 , 11250c317acSBruce M Simpson.Xr getgrnam_r 3 , 11350c317acSBruce M Simpson.Xr setgrent 3 , 11450c317acSBruce M Simpson.Xr endgrent 3 115d0353b83SRuslan Ermilov.It hosts 11650c317acSBruce M Simpson.Xr getaddrinfo 3 , 11750c317acSBruce M Simpson.Xr gethostbyaddr 3 , 11850c317acSBruce M Simpson.Xr gethostbyaddr_r 3 , 11950c317acSBruce M Simpson.Xr gethostbyname 3 , 12050c317acSBruce M Simpson.Xr gethostbyname2 3 , 12150c317acSBruce M Simpson.Xr gethostbyname_r 3 , 12250c317acSBruce M Simpson.Xr getipnodebyaddr 3 , 12350c317acSBruce M Simpson.Xr getipnodebyname 3 124d0353b83SRuslan Ermilov.It networks 12550c317acSBruce M Simpson.Xr getnetbyaddr 3 , 12650c317acSBruce M Simpson.Xr getnetbyaddr_r 3 , 12750c317acSBruce M Simpson.Xr getnetbyname 3 , 12850c317acSBruce M Simpson.Xr getnetbyname_r 3 129d0353b83SRuslan Ermilov.It passwd 13050c317acSBruce M Simpson.Xr getpwent 3 , 13150c317acSBruce M Simpson.Xr getpwent_r 3 , 13250c317acSBruce M Simpson.Xr getpwnam_r 3 , 13350c317acSBruce M Simpson.Xr getpwuid_r 3 , 13450c317acSBruce M Simpson.Xr setpwent 3 , 13550c317acSBruce M Simpson.Xr endpwent 3 136d0353b83SRuslan Ermilov.It shells 137248aee62SJacques Vidrine.Xr getusershell 3 138a8cceff8SHajimu UMEMOTO.It services 139a8cceff8SHajimu UMEMOTO.Xr getservent 3 140a8cceff8SHajimu UMEMOTO.It rpc 14150c317acSBruce M Simpson.Xr getrpcbyname 3 , 14250c317acSBruce M Simpson.Xr getrpcbynumber 3 , 143a8cceff8SHajimu UMEMOTO.Xr getrpcent 3 144a8cceff8SHajimu UMEMOTO.It proto 145d194e583STom Rhodes.Xr getprotobyname 3 , 14650c317acSBruce M Simpson.Xr getprotobynumber 3 , 14750c317acSBruce M Simpson.Xr getprotoent 3 148d194e583STom Rhodes.It netgroup 149d194e583STom Rhodes.Xr getnetgrent 3 , 150714ac002SMark Johnston.Xr getnetgrent_r 3 , 151d194e583STom Rhodes.Xr setnetgrent 3 , 152714ac002SMark Johnston.Xr endnetgrent 3 , 153d194e583STom Rhodes.Xr innetgr 3 154248aee62SJacques Vidrine.El 155248aee62SJacques Vidrine.Ss Status codes 156248aee62SJacques VidrineThe following status codes are available: 157d0353b83SRuslan Ermilov.Pp 158d0353b83SRuslan Ermilov.Bl -tag -width tryagain -compact 159d0353b83SRuslan Ermilov.It Sy Status 160d0353b83SRuslan Ermilov.Sy Description 161d0353b83SRuslan Ermilov.It success 162d0353b83SRuslan ErmilovThe requested entry was found. 163d0353b83SRuslan Ermilov.It notfound 164d0353b83SRuslan ErmilovThe entry is not present at this source. 165d0353b83SRuslan Ermilov.It tryagain 166d0353b83SRuslan ErmilovThe source is busy, and may respond to retries. 167d0353b83SRuslan Ermilov.It unavail 168d0353b83SRuslan ErmilovThe source is not responding, or entry is corrupt. 169248aee62SJacques Vidrine.El 170248aee62SJacques Vidrine.Ss Actions 171248aee62SJacques VidrineFor each of the status codes, one of two actions is possible: 172d0353b83SRuslan Ermilov.Pp 173d0353b83SRuslan Ermilov.Bl -tag -width continue -compact 174d0353b83SRuslan Ermilov.It Sy Action 175d0353b83SRuslan Ermilov.Sy Description 176d0353b83SRuslan Ermilov.It continue 177d0353b83SRuslan ErmilovTry the next source 178d0353b83SRuslan Ermilov.It return 179d0353b83SRuslan ErmilovReturn with the current result 180248aee62SJacques Vidrine.El 181248aee62SJacques Vidrine.Ss Format of file 182*5e20b96cSAlan SomersA BNF description of the syntax of 183248aee62SJacques Vidrine.Nm 184248aee62SJacques Vidrineis: 185d0353b83SRuslan Ermilov.Pp 186d0353b83SRuslan Ermilov.Bl -tag -width <criterion> -compact 187d0353b83SRuslan Ermilov.It <entry> 188d0353b83SRuslan Ermilov::= 189248aee62SJacques Vidrine<database> ":" [<source> [<criteria>]]* 190d0353b83SRuslan Ermilov.It <criteria> 191d0353b83SRuslan Ermilov::= 192248aee62SJacques Vidrine"[" <criterion>+ "]" 193d0353b83SRuslan Ermilov.It <criterion> 194d0353b83SRuslan Ermilov::= 195248aee62SJacques Vidrine<status> "=" <action> 196d0353b83SRuslan Ermilov.It <status> 197d0353b83SRuslan Ermilov::= 198248aee62SJacques Vidrine"success" | "notfound" | "unavail" | "tryagain" 199d0353b83SRuslan Ermilov.It <action> 200d0353b83SRuslan Ermilov::= 201248aee62SJacques Vidrine"return" | "continue" 202248aee62SJacques Vidrine.El 203248aee62SJacques Vidrine.Pp 204248aee62SJacques VidrineEach entry starts on a new line in the file. 205248aee62SJacques VidrineA 206248aee62SJacques Vidrine.Sq # 207248aee62SJacques Vidrinedelimits a comment to end of line. 208248aee62SJacques VidrineBlank lines are ignored. 209248aee62SJacques VidrineA 210248aee62SJacques Vidrine.Sq \e 211248aee62SJacques Vidrineat the end of a line escapes the newline, and causes the next line to 212248aee62SJacques Vidrinebe a continuation of the current line. 213248aee62SJacques VidrineAll entries are case-insensitive. 214248aee62SJacques Vidrine.Pp 215248aee62SJacques VidrineThe default criteria is to return on 216248aee62SJacques Vidrine.Dq success , 217248aee62SJacques Vidrineand continue on anything else (i.e, 21894ba280cSRuslan Ermilov.Li "[success=return notfound=continue unavail=continue tryagain=continue]" ) . 219a8cceff8SHajimu UMEMOTO.Ss Cache 220a8cceff8SHajimu UMEMOTOYou can enable caching for the particular database by specifying 221a8cceff8SHajimu UMEMOTO.Dq cache 22204bd07fdSAlan Somersin the 22316e36754SEdward Tomasz Napierala.Nm 224a8cceff8SHajimu UMEMOTOfile. 22504bd07fdSAlan SomersIt should come after 22604bd07fdSAlan Somers.Dq files , 22704bd07fdSAlan Somersbut before remote sources like 22804bd07fdSAlan Somers.Dq nis . 229a8cceff8SHajimu UMEMOTOYou should also enable caching for this database in 23044726a59SMichael Bushkov.Xr nscd.conf 5 . 23104bd07fdSAlan SomersIf for a particular query 232a8cceff8SHajimu UMEMOTO.Dq cache 23304bd07fdSAlan Somerssource returns success, then no further sources are queried. 234a8cceff8SHajimu UMEMOTOOn the other hand, if there are no previously cached data, the 235a8cceff8SHajimu UMEMOTOquery result will be placed into the cache right after 236a8cceff8SHajimu UMEMOTOall other sources are processed. 23704bd07fdSAlan SomersNote that 238a8cceff8SHajimu UMEMOTO.Dq cache 23904bd07fdSAlan Somersrequires the 24044726a59SMichael Bushkov.Xr nscd 8 241a8cceff8SHajimu UMEMOTOdaemon to be running. 242248aee62SJacques Vidrine.Ss Compat mode: +/- syntax 243248aee62SJacques VidrineIn historical multi-source implementations, the 244248aee62SJacques Vidrine.Sq + 245248aee62SJacques Vidrineand 246248aee62SJacques Vidrine.Sq - 247248aee62SJacques Vidrinecharacters are used to specify the importing of user password and 248*5e20b96cSAlan Somersgroup information from NIS . 249248aee62SJacques VidrineAlthough 250248aee62SJacques Vidrine.Nm 251*5e20b96cSAlan Somersprovides alternative methods of accessing distributed sources such as NIS , 252248aee62SJacques Vidrinespecifying a sole source of 253248aee62SJacques Vidrine.Dq compat 254248aee62SJacques Vidrinewill provide the historical behaviour. 255248aee62SJacques Vidrine.Pp 256248aee62SJacques VidrineAn alternative source for the information accessed via 257248aee62SJacques Vidrine.Sq +/- 258248aee62SJacques Vidrinecan be used by specifying 259248aee62SJacques Vidrine.Dq passwd_compat: source . 260248aee62SJacques Vidrine.Dq source 261248aee62SJacques Vidrinein this case can be 262248aee62SJacques Vidrine.Sq dns , 263248aee62SJacques Vidrine.Sq nis , 264248aee62SJacques Vidrineor 265248aee62SJacques Vidrineany other source except for 266248aee62SJacques Vidrine.Sq files 267248aee62SJacques Vidrineand 268248aee62SJacques Vidrine.Sq compat . 269248aee62SJacques Vidrine.Ss Notes 270248aee62SJacques VidrineHistorically, many of the databases had enumeration functions, often of 271248aee62SJacques Vidrinethe form 272248aee62SJacques Vidrine.Fn getXXXent . 2730227791bSRuslan ErmilovThese made sense when the databases were in local files, but do not make 274248aee62SJacques Vidrinesense or have lesser relevance when there are possibly multiple sources, 275248aee62SJacques Vidrineeach of an unknown size. 276248aee62SJacques VidrineThe interfaces are still provided for compatibility, but the source 277248aee62SJacques Vidrinemay not be able to provide complete entries, or duplicate entries may 278248aee62SJacques Vidrinebe retrieved if multiple sources that contain similar information are 279248aee62SJacques Vidrinespecified. 280248aee62SJacques Vidrine.Pp 281248aee62SJacques VidrineTo ensure compatibility with previous and current implementations, the 282248aee62SJacques Vidrine.Dq compat 283248aee62SJacques Vidrinesource must appear alone for a given database. 284248aee62SJacques Vidrine.Ss Default source lists 285248aee62SJacques VidrineIf, for any reason, 2864b66483fSRuslan Ermilov.Nm 2870227791bSRuslan Ermilovdoes not exist, or it has missing or corrupt entries, 288248aee62SJacques Vidrine.Xr nsdispatch 3 289248aee62SJacques Vidrinewill default to an entry of 290248aee62SJacques Vidrine.Dq files 291248aee62SJacques Vidrinefor the requested database. 292248aee62SJacques VidrineExceptions are: 293d0353b83SRuslan Ermilov.Pp 294a8cceff8SHajimu UMEMOTO.Bl -tag -width services_compat -compact 295d0353b83SRuslan Ermilov.It Sy Database 296d0353b83SRuslan Ermilov.Sy "Default source list" 297d0353b83SRuslan Ermilov.It group 298d0353b83SRuslan Ermilovcompat 299d0353b83SRuslan Ermilov.It group_compat 300d0353b83SRuslan Ermilovnis 301d0353b83SRuslan Ermilov.It hosts 3021c035a6eSDag-Erling Smørgravfiles dns 303d0353b83SRuslan Ermilov.It passwd 304d0353b83SRuslan Ermilovcompat 305d0353b83SRuslan Ermilov.It passwd_compat 306d0353b83SRuslan Ermilovnis 307a8cceff8SHajimu UMEMOTO.It services 308a8cceff8SHajimu UMEMOTOcompat 309a8cceff8SHajimu UMEMOTO.It services_compat 310a8cceff8SHajimu UMEMOTOnis 311248aee62SJacques Vidrine.El 312248aee62SJacques Vidrine.Sh FILES 313248aee62SJacques Vidrine.Bl -tag -width /etc/nsswitch.conf -compact 314248aee62SJacques Vidrine.It Pa /etc/nsswitch.conf 315248aee62SJacques VidrineThe file 316248aee62SJacques Vidrine.Nm 317248aee62SJacques Vidrineresides in 318248aee62SJacques Vidrine.Pa /etc . 319248aee62SJacques Vidrine.El 320248aee62SJacques Vidrine.Sh EXAMPLES 32104bd07fdSAlan SomersTo lookup hosts in 322248aee62SJacques Vidrine.Pa /etc/hosts 32304bd07fdSAlan Somers, then in cache, 324*5e20b96cSAlan Somersand then from the DNS, and lookup user information from NIS then files, use: 325d0353b83SRuslan Ermilov.Pp 326d0353b83SRuslan Ermilov.Bl -tag -width passwd: -compact 327d0353b83SRuslan Ermilov.It hosts: 32804bd07fdSAlan Somersfiles cache dns 329d0353b83SRuslan Ermilov.It passwd: 330d0353b83SRuslan Ermilovnis [notfound=return] files 331d0353b83SRuslan Ermilov.It group: 332d0353b83SRuslan Ermilovnis [notfound=return] files 333248aee62SJacques Vidrine.El 334248aee62SJacques Vidrine.Pp 335248aee62SJacques VidrineThe criteria 336248aee62SJacques Vidrine.Dq [notfound=return] 3370227791bSRuslan Ermilovsets a policy of "if the user is notfound in nis, do not try files." 338f1d353ecSJens SchweikhardtThis treats nis as the authoritative source of information, except 339248aee62SJacques Vidrinewhen the server is down. 340313d0277SBjoern A. Zeeb.Sh NOTES 3418d113f4aSEdward Tomasz NapieralaThe 3428d113f4aSEdward Tomasz Napierala.Nm 3438d113f4aSEdward Tomasz Napieralafile is parsed by each program only once. 3448d113f4aSEdward Tomasz NapieralaSubsequent changes will not be applied until the program 3458d113f4aSEdward Tomasz Napieralais restarted. 3468d113f4aSEdward Tomasz Napierala.Pp 347313d0277SBjoern A. ZeebIf system got compiled with 348e1fe3dbaSRuslan Ermilov.Va WITHOUT_NIS 349313d0277SBjoern A. Zeebyou have to remove 350313d0277SBjoern A. Zeeb.Sq nis 351313d0277SBjoern A. Zeebentries. 35250c317acSBruce M Simpson.Pp 35350c317acSBruce M Simpson.Fx Ns 's 35450c317acSBruce M Simpson.Lb libc 35550c317acSBruce M Simpsonprovides stubs for compatibility with NSS modules 356*5e20b96cSAlan Somerswritten for the GNU C Library 35750c317acSBruce M Simpson.Nm nsswitch 35850c317acSBruce M Simpsoninterface. 35950c317acSBruce M SimpsonHowever, these stubs only support the use of the 36050c317acSBruce M Simpson.Dq Li passwd 36150c317acSBruce M Simpsonand 36250c317acSBruce M Simpson.Dq Li group 36350c317acSBruce M Simpsondatabases. 364248aee62SJacques Vidrine.Sh SEE ALSO 365248aee62SJacques Vidrine.Xr nsdispatch 3 , 36644726a59SMichael Bushkov.Xr nscd.conf 5 , 367248aee62SJacques Vidrine.Xr resolv.conf 5 , 36844726a59SMichael Bushkov.Xr nscd 8 , 36930550483SMaxim Konovalov.Xr ypbind 8 370248aee62SJacques Vidrine.Sh HISTORY 371248aee62SJacques VidrineThe 372248aee62SJacques Vidrine.Nm 373248aee62SJacques Vidrinefile format first appeared in 3746883c2e5STom Rhodes.Fx 5.0 . 375248aee62SJacques VidrineIt was imported from the 376248aee62SJacques Vidrine.Nx 377248aee62SJacques VidrineProject, where it appeared first in 378248aee62SJacques Vidrine.Nx 1.4 . 379248aee62SJacques Vidrine.Sh AUTHORS 380a63d6c94SBaptiste Daroussin.An Luke Mewburn Aq Mt lukem@netbsd.org 381248aee62SJacques Vidrinewrote this freely distributable name-service switch implementation, 382*5e20b96cSAlan Somersusing ideas from the ULTRIX 383248aee62SJacques Vidrine.Xr svc.conf 5 384*5e20b96cSAlan Somersand Solaris 385248aee62SJacques Vidrine.Xr nsswitch.conf 4 386248aee62SJacques Vidrinemanual pages. 387