Main index | Section 5 | 日本語 | Options |
The configuration file controls how a process looks up various databases containing information regarding hosts, users (passwords), groups, etc. Each database comes from a source (such as local files, DNS, NIS , and cache), and the order to look up the sources is specified in nsswitch.conf.
Each entry in nsswitch.conf consists of a database name, and a space separated list of sources. Each source can have an optional trailing criterion that determines whether the next listed source is used, or the search terminates at the current source. Each criterion consists of one or more status codes, and actions to take if that status code occurs.
Source | |
Description | |
files | Local files, such as /etc/hosts, and /etc/passwd. |
db | Local database. |
dns | Internet Domain Name System. "hosts" and 'networks' use IN class entries, all other databases use HS class (Hesiod) entries. |
nis | NIS (formerly YP) |
compat | |
support '+/-' in the "passwd" and "group" databases. If this is present, it must be the only source for that entry. | |
cache | makes use of the nscd(8) daemon. |
Database | |
Used by | |
group | getgrent(3), getgrent_r(3), getgrgid_r(3), getgrnam_r(3), setgrent(3), endgrent(3) |
hosts | getaddrinfo(3), gethostbyaddr(3), gethostbyaddr_r(3), gethostbyname(3), gethostbyname2(3), gethostbyname_r(3), getipnodebyaddr(3), getipnodebyname(3) |
networks | |
getnetbyaddr(3), getnetbyaddr_r(3), getnetbyname(3), getnetbyname_r(3) | |
passwd | getpwent(3), getpwent_r(3), getpwnam_r(3), getpwuid_r(3), setpwent(3), endpwent(3) |
shells | getusershell(3) |
services | |
getservent(3) | |
rpc | getrpcbyname(3), getrpcbynumber(3), getrpcent(3) |
proto | getprotobyname(3), getprotobynumber(3), getprotoent(3) |
netgroup | |
getnetgrent(3), getnetgrent_r(3), setnetgrent(3), endnetgrent(3), innetgr(3) | |
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. |
Action | Description |
continue | |
Try the next source | |
return | Return with the current result |
<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]).
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'.
To ensure compatibility with previous and current implementations, the "compat" source must appear alone for a given database.
Database | Default source list |
group | compat |
group_compat | nis |
hosts | files dns |
passwd | compat |
passwd_compat | nis |
services | compat |
services_compat | |
nis | |
/etc/nsswitch.conf | |
The file nsswitch.conf resides in /etc. | |
hosts: | files cache 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.
FreeBSD Ns 's Standard C Library (libc, -lc)provides stubs for compatibility with NSS modules written for the GNU C Library nsswitch interface. However, these stubs only support the use of the "passwd" and "group" databases.
NSSWITCH.CONF (5) | September 6, 2020 |
Main index | Section 5 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | If at first you don't succeed, you must be a programmer. | ” |