|
nsswitch.conf(5)
Contents
|
nsswitch.conf - name-service switch configuration file
The nsswitch.conf file specifies how the nsdispatch(3)
(name-service switch dispatcher) routines in the C library
should operate.
The configuration file controls how a process looks up
various databases containing information regarding hosts,
users (passwords), groups, net-groups, etc. Each database
comes from a source (such as local files, DNS, and NIS),
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.
Sources [Toc] [Back]
The following sources may be used: Description Local
files, such as /etc/hosts and /etc/passwd. Internet
Domain Name System. ``hosts'' and `networks' use IN class
entries, all other databases use HS class (Hesiod)
entries. NIS (formerly YP) support `+/-' in the
``passwd'' and ``group'' databases. If this is present, it
must be the only source for that entry.
Databases [Toc] [Back]
The following databases use the switch: Used by getesdfent()
getesdvent() getesfient() getespwent() getestcent()
getgrent() gethostbyname() getnetgrent() getnetbyname()
getpwent() getprotobyname() getrpcent() getnameinfo()
Status Codes [Toc] [Back]
The following status codes are available: Codes The
requested entry was found. The entry was not present at
this source. The source is busy and may respond to
retires. The source is not responding, or entry is corrupt.
Actions [Toc] [Back]
For each of the status codes, one if two actions is possible:
Description Try the next source. Return with the
current result.
Format of the File [Toc] [Back]
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] ).
Compat Mode: +/- syntax
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'.
Notes [Toc] [Back]
Historically, many of the databases had enumeration functions,
often of the form getXXXent(). These made sense
when the databases were in local files, but don't 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.
Default Source Lists [Toc] [Back]
If, for any reason, nsswitch.conf doesn't exist, or it has
missing or corrupt entries, nsdispatch(3) will default to
an entry of ``files'' for the requested database. Exceptions
are: Default Source List compat nis files dns files
[notfound=return] nis compat nis
/etc/nsswitch.conf
To look up 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 not found in nis, don't try files." This
treats nis as the authoritative source of information,
except when the server is down.
getesdfent(3), getesdvent(3), getesfient(3), getespwent(3), getestcent(3), getgrent()getprent(3), gethostbyname(3), getnetgrent(3), getnetbyname(3), getpwent(3),
getprotobyname(3), getnameinfo(3), nsdispatch(3)
nsswitch.conf(5)
[ Back ] |