|files||Local files, such as /etc/hosts, and /etc/passwd.|
|dns||Internet Domain Name System. "hosts" and 'networks' use IN class entries, all other databases use HS class (Hesiod) entries.|
|nis||NIS (formerly YP)|
|support '+/-' in the "passwd" and "group" databases. If this is present, it must be the only source for that entry.|
The following databases are used by the following C library functions:
Database Used by group getgrent(3) hosts gethostbyname(3) networks getnetbyname(3) passwd getpwent(3) shells getusershell(3)
The following status codes are available:
Status Description success The requested entry was found. notfound The entry is not present at this source. tryagain The source is busy, and may respond to retries. unavail The source is not responding, or entry is corrupt.
For each of the status codes, one of two actions is possible:
Action Description continue Try the next source return Return with the current result
A BNF description of the syntax of nsswitch.conf is:
<entry> ::= <database> ":" [<source> [<criteria>]]* <criteria> ::= "[" <criterion>+ "]" <criterion> ::= <status> "=" <action> <status> ::= "success" | "notfound" | "unavail" | "tryagain" <action> ::= "return" | "continue"
Each entry starts on a new line in the file. A '#' delimits a comment to end of line. Blank lines are ignored. A '\' at the end of a line escapes the newline, and causes the next line to be a continuation of the current line. All entries are case-insensitive.
The default criteria is to return on "success", and continue on anything else (i.e, [success=return notfound=continue unavail=continue tryagain=continue]).
In historical multi-source implementations, the '+' and '-' characters are used to specify the importing of user password and group information from NIS. Although nsswitch.conf provides alternative methods of accessing distributed sources such as NIS, specifying a sole source of "compat" will provide the historical behaviour.
An alternative source for the information accessed via '+/-' can be used by specifying "passwd_compat: source". "source" in this case can be 'dns', 'nis', or any other source except for 'files' and 'compat'.
Historically, many of the databases had enumeration functions, often of the form getXXXent. These made sense when the databases were in local files, but do not make sense or have lesser relevance when there are possibly multiple sources, each of an unknown size. The interfaces are still provided for compatibility, but the source may not be able to provide complete entries, or duplicate entries may be retrieved if multiple sources that contain similar information are specified.
To ensure compatibility with previous and current implementations, the "compat" source must appear alone for a given database.
If, for any reason, nsswitch.conf does not exist, or it has missing or corrupt entries, nsdispatch(3) will default to an entry of "files" for the requested database. Exceptions are:
Database Default source list group compat group_compat nis hosts files dns passwd compat passwd_compat nis
/etc/nsswitch.conf The file nsswitch.conf resides in /etc.
To lookup hosts in /etc/hosts and then from the DNS, and lookup user information from NIS then files, use:
hosts: files dns passwd: nis [notfound=return] files group: nis [notfound=return] files
The criteria "[notfound=return]" sets a policy of "if the user is notfound in nis, do not try files." This treats nis as the authoritative source of information, except when the server is down.
If system got compiled with NO_NIS you have to remove 'nis' entries.
nsdispatch(3), resolv.conf(5), named(8), ypbind(8)
The nsswitch.conf file format first appeared in
.Fx 5.0 . It was imported from the
.Nx Project, where it appeared first in
.Nx 1.4 .
Luke Mewburn <firstname.lastname@example.org> wrote this freely distributable name-service switch implementation, using ideas from the ULTRIX svc.conf(5) and Solaris nsswitch.conf(4) manual pages.
|April 24, 2005||NSSWITCH.CONF (5)|