<?Pub UDT _bookmark _target?><?Pub CX solbook(?><chapter id="a12swit-86415"><?Pub Tag atict:info tracking="off" ref="0"?><?Pub Tag
atict:user user="sharonr" fullname="Sharon Veach"?><?Pub Tag atict:user
user="ee194360" fullname="ERIC ERICKSON"?><?Pub Tag atict:user user="mseif"
fullname=""?><title>The Name Service Switch (Overview)</title><highlights><para>This chapter describes the name service switch. You use the name service
switch to coordinate usage of different naming services.</para>
</highlights><sect1 id="a12swit-89620"><title>About the Name Service Switch</title><para><indexterm significance="preferred"><primary><filename>nsswitch.conf</filename> file</primary><secondary>introduction</secondary></indexterm><indexterm><primary><function>getXbyY</function></primary></indexterm>The name service switch is a file
which is named,  <filename>nsswitch.conf</filename>. The name service switch
controls how a client machine or application obtains network information.
The name service switch is used by client applications that call any of the <function>getXbyY</function> interfaces such as the following.</para><itemizedlist><listitem><para><indexterm><primary><function>gethostbyname</function></primary><secondary>name service switch and</secondary></indexterm><function>gethostbyname</function></para>
</listitem><listitem><para><indexterm><primary><function>getpwuid</function></primary><secondary>name service switch and</secondary></indexterm><function>getpwuid</function></para>
</listitem><listitem><para><indexterm><primary><function>getpwnam</function></primary><secondary>name service switch and</secondary></indexterm><function>getpwnam</function></para>
</listitem><listitem><para><indexterm><primary><function>getaddrinfo</function></primary><secondary>name service switch and</secondary></indexterm><function>getaddrinfo</function></para>
</listitem>
</itemizedlist><para>Each machine has a switch file in its <filename>/etc</filename> directory.
Each line of that file identifies a particular type of network information,
such as host, password, and group, followed by one or more locations of that
information.</para><para>A client can obtain naming information from one or more of the switch's
sources. For example, an NIS+ client could obtain its hosts information from
an NIS+ table and its password information from a local <filename>/etc</filename> file.
In addition, the client could specify the conditions under which the switch
must use each source. See <olink targetptr="a12swit-tbl-1" remap="internal">Table&nbsp;2&ndash;1</olink>.</para><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>templates</secondary></indexterm>The Solaris system automatically
loads an <filename>nsswitch.conf</filename> file into every machine's <filename>/etc</filename> directory as part of the installation process. Four alternate
(template) versions of the switch file are also loaded into <filename>/etc</filename> for
LDAP, NIS, NIS+, or files. See <olink targetptr="a12swit-22067" remap="internal">The nsswitch.conf
Template Files</olink>.</para><para>These four files are alternate default switch files. Each file is designed
for a different primary naming service: <filename>/etc</filename> files, NIS,
NIS+, or LDAP. When  the Solaris software is first installed on a machine,
the installer selects the machine's default naming service: NIS+, NIS, local
files, or LDAP. During installation, the corresponding template file is copied
to <filename>nsswitch.conf</filename>. For example, for a machine client using
LDAP, the installation process copies  <filename>nsswitch.ldap</filename> to <filename>nsswitch.conf</filename>. Unless you have an unusual namespace, the default
template file as copied to <filename>nsswitch.conf</filename> should be sufficient
for normal operation.</para><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>DNS and</secondary></indexterm><indexterm><primary>DNS</primary><secondary><filename>nsswitch.conf</filename> file and</secondary></indexterm>No
default file is provided for DNS, but you can edit any of these files to use
DNS. For more information see <olink targetptr="a12swit-66520" remap="internal">DNS and Internet
Access</olink>.</para><para>If you later change a machine's primary naming service, you copy the
appropriate alternate switch file to <filename>nsswitch.conf</filename>. See <olink targetptr="a12swit-22067" remap="internal">The nsswitch.conf Template Files</olink>. You can
also change the sources of particular types of network information used by
the client by editing the appropriate lines of the <filename>/etc/nsswitch.conf</filename> file.
The syntax is described below, and additional instructions are provided in <olink targetptr="c8switch-2" remap="internal">How to Modify the Name Service Switch</olink>.</para><sect2 id="a12swit-84565"><title>Format of the <filename>nsswitch.conf</filename> File</title><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>format of</secondary></indexterm>The <filename>nsswitch.conf</filename> file
is essentially a list of 16 types of information and the sources that <function>getXXbyYY</function> routines search for that information. The 16 types of information,
not necessarily in this order, are the following.</para><itemizedlist><listitem><para><literal>aliases</literal></para>
</listitem><listitem><para><literal>bootparams</literal></para>
</listitem><listitem><para><literal>ethers</literal></para>
</listitem><listitem><para><literal>group</literal></para>
</listitem><listitem><para><literal>hosts</literal></para>
</listitem><listitem><para><literal>ipnodes</literal></para>
</listitem><listitem><para><literal>netgroup</literal></para>
</listitem><listitem><para><literal>netmasks</literal></para>
</listitem><listitem><para><literal>networks</literal></para>
</listitem><listitem><para><literal>passwd</literal>, which includes shadow information</para>
</listitem><listitem><para><literal>protocols</literal></para>
</listitem><listitem><para><literal>publickey</literal></para>
</listitem><listitem><para><literal>rpc</literal></para>
</listitem><listitem><para><literal>services</literal></para>
</listitem><listitem><para><literal>automount</literal></para>
</listitem><listitem><para><literal>sendmailvars</literal></para>
</listitem>
</itemizedlist><para>The following table provides a description of the kind of sources that
can be listed in the switch file for the information types above.</para><table frame="topbot" id="a12swit-tbl-1"><title>Switch File Information Sources</title><tgroup cols="2" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="76.87*"/><colspec colname="colspec1" colwidth="319.13*"/><thead><row valign="bottom"><entry align="left"><para>Information Sources</para>
</entry><entry align="left"><para>Description</para>
</entry>
</row>
</thead><tbody><row><entry align="left" valign="top"><para><literal>files</literal></para>
</entry><entry align="left" valign="top"><para>A file stored in the client's <filename>/etc</filename> directory. For
example, <filename>/etc/passwd</filename></para>
</entry>
</row><row><entry align="left" valign="top"><para><literal>nisplus</literal></para>
</entry><entry align="left" valign="top"><para>An NIS+ table. For example, the <literal>hosts</literal> table.</para>
</entry>
</row><row><entry align="left" valign="top"><para><literal>nis</literal></para>
</entry><entry align="left" valign="top"><para>An NIS map. For example, the <literal>hosts</literal> map.</para>
</entry>
</row><row><entry align="left" valign="top"><para><literal>compat</literal></para>
</entry><entry align="left" valign="top"><para><literal>compat</literal> can be used for password and group information
to support old-style + or - syntax in <filename>/etc/passwd</filename>, <filename>/etc/shadow</filename>, and <filename>/etc/group</filename> files.</para>
</entry>
</row><row><entry align="left" valign="top"><para><literal>dns</literal></para>
</entry><entry align="left" valign="top"><para>Can be used to specify that host information be obtained from DNS.</para>
</entry>
</row><row><entry colname="colspec0"><para><literal>ldap</literal></para>
</entry><entry colname="colspec1"><para>Can be used to specify entries be obtained from the LDAP directory.</para>
</entry>
</row>
</tbody>
</tgroup>
</table><sect3 id="a12swit-39858"><title>Search Criteria</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>search criteria</secondary>
</indexterm><para><emphasis>Single Source.</emphasis> If an information type has only
one source, such as <literal>nisplus</literal> a routine using the switch
searches for the information in that source <emphasis>only</emphasis>. If
the routine finds the information, the routine returns a <returnvalue>success</returnvalue> status
message. If the routine does not find the information, the routine stops searching
and returns a different status message. What the routine does with the status
message varies from routine to routine.</para><para><emphasis>Multiple Sources.</emphasis>  If a table contains multiple
sources for a given information type, the switch directs the routine to  search
in the first listed source. If the routine finds the information, the routine
returns a <returnvalue>success</returnvalue> status message. If the routine
does not find the information in the first source, the routine tries the next
source. The routine searches  all sources until the routine has found the
information, or until the routine is halted by a <literal>return</literal> specification.
If all of the listed sources are searched without finding the information,
the routine stops searching and returns a <returnvalue>non-success</returnvalue> status
message.</para>
</sect3><sect3 id="a12swit-2"><title>Switch Status Messages</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>status messages</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>messages</secondary>
</indexterm><para>If a routine finds the information, the routine returns a <returnvalue>success</returnvalue> status message. If the routine does not find the information,
the routine returns one of three error status messages. Possible status messages
are listed in the following table.</para><table id="a12swit-tbl-3111"><title>Switch Search Status Messages</title><tgroup cols="2" colsep="1" rowsep="1"><colspec colwidth="88*"/><colspec colwidth="308*"/><thead><row valign="bottom"><entry align="left"><para>Status Message</para>
</entry><entry align="left"><para>Meaning of Message</para>
</entry>
</row>
</thead><tbody><row><entry align="left" valign="top"><para><returnvalue>SUCCESS</returnvalue></para>
</entry><entry align="left" valign="top"><para>The requested entry was found in the specified source.</para>
</entry>
</row><row><entry align="left" valign="top"><para><returnvalue>UNAVAIL</returnvalue></para>
</entry><entry align="left" valign="top"><para>The source is either unresponsive or  unavailable. In other words, neither
the NIS+ table, the NIS map, nor the <filename>/etc</filename> file could
be found or be accessed.</para>
</entry>
</row><row><entry align="left" valign="top"><para><returnvalue>NOTFOUND</returnvalue></para>
</entry><entry align="left" valign="top"><para>The source responded with &ldquo;No such entry.&rdquo; In other words,
the table, map, or file was accessed but the needed information was not found.</para>
</entry>
</row><row><entry align="left" valign="top"><para><returnvalue>TRYAGAIN</returnvalue></para>
</entry><entry align="left" valign="top"><para>The source is busy. The source might respond next time. In other words,
the table, map, or file was found, but could not respond to the query.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3><sect3 id="a12swit-3"><title>Switch Action Options</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>actions</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>options</secondary>
</indexterm><para>You can instruct the switch to respond to status messages with either
of the two <emphasis>actions</emphasis> shown in the following table.</para><table frame="topbot" id="a12swit-32878"><title>Responses to Switch Status
Messages</title><tgroup cols="2" colsep="0" rowsep="1"><colspec colname="column1" colwidth="88*"/><colspec colname="column2" colwidth="308*"/><thead><row><entry align="left" valign="bottom"><para>Action</para>
</entry><entry align="left" valign="bottom"><para>Meaning</para>
</entry>
</row>
</thead><tbody><row rowsep="0"><entry align="left" valign="top"><para><returnvalue>return</returnvalue></para>
</entry><entry align="left" valign="top"><para>Stop looking for the information.</para>
</entry>
</row><row><entry align="left" valign="top"><para><returnvalue>continue</returnvalue></para>
</entry><entry align="left" valign="top"><para>Try the next source.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3><sect3 id="a12swit-4"><title>Default Search Criteria</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>search criteria</secondary>
</indexterm><para>The combination of <filename>nsswitch.conf</filename> file status message
and action option determines what the routine does at each step. The combination
of status and action make up the search <emphasis>criteria</emphasis>.</para><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>status messages</secondary></indexterm>The switch's default search
criteria are the same for every source. As described in terms of the status
messages listed above, see the following.</para><itemizedlist><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><returnvalue>SUCCESS=return</returnvalue></secondary></indexterm><returnvalue>SUCCESS=return</returnvalue>. Stop looking for the information. Proceed using
the information that has been found.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><returnvalue>UNAVAIL=continue</returnvalue></secondary></indexterm><returnvalue>UNAVAIL=continue</returnvalue>. Go to the next <filename>nsswitch.conf</filename> file
source and continue searching. If this source is the last or only source,
return with a <returnvalue>NOTFOUND</returnvalue> status.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><returnvalue>NOTFOUND=continue</returnvalue></secondary></indexterm><returnvalue>NOTFOUND=continue</returnvalue>. Go to the next <filename>nsswitch.conf</filename> file
source and continue searching. If this source is the last or only source,
return with a <returnvalue>NOTFOUND</returnvalue> status.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><returnvalue>TRYAGAIN=continue</returnvalue></secondary></indexterm><returnvalue>TRYAGAIN=continue</returnvalue>. Go to the next <filename>nsswitch.conf</filename> file
source and continue searching. If this source is the last or only source,
return with a <returnvalue>NOTFOUND</returnvalue> status.</para>
</listitem>
</itemizedlist><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>modifying</secondary></indexterm>You can change default search
criteria by explicitly specifying some other criteria by using the <replaceable>STATUS=action</replaceable> syntax shown above. For example, the default action for a <returnvalue>NOTFOUND</returnvalue> condition is to continue the search to the next source.
For example, to specify for  <literal>networks</literal>, the search should
stop in  a  <returnvalue>NOTFOUND</returnvalue> condition, edit the <literal>networks</literal> line of the switch file. The line would read as follows.</para><screen>networks: nis [NOTFOUND=return] files</screen><para>The <literal>networks: nis [NOTFOUND=return] files</literal> line specifies
a nondefault criterion for the <returnvalue>NOTFOUND</returnvalue> status.
Nondefault criteria are delimited by square brackets.</para><para>In this example, the search routine behaves as follows:</para><itemizedlist><listitem><para>If the <literal>networks</literal> map is available, and contains
the needed information, the routine returns with a <returnvalue>SUCCESS</returnvalue> status
message.</para>
</listitem><listitem><para>If the <literal>networks</literal> map is not available, the
routine returns with an <returnvalue>UNAVAIL</returnvalue> status message.
By default, the routine continues to search the appropriate <filename>/etc</filename> file.</para>
</listitem><listitem><para>If the <literal>networks</literal> map is available and found,
but the map does not contain the needed information, the routine returns with
a <returnvalue>NOTFOUND</returnvalue> message. But, instead of continuing
on to search the appropriate <filename>/etc</filename> file, which would be
the default behavior, the routine stops searching.</para>
</listitem><listitem><para>If the <literal>networks</literal> map is busy, the routine
returns with an <returnvalue>TRYAGAIN</returnvalue> status message and by
default continues on to search the appropriate <filename>/etc</filename> file.</para>
</listitem>
</itemizedlist><note><para>Lookups in the <filename>nsswitch.conf</filename> file are done
in the order in which items are listed. However, password updates are done
in reverse order, unless otherwise specified by using the <command>passwd</command> <option>r</option> <replaceable>repository</replaceable> command. See <olink targetptr="a12swit-27155" remap="internal">The Switch File and Password Information</olink> for
more information.</para>
</note>
</sect3><sect3 id="a12swit-4a"><title>What if the Syntax is Wrong?</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>missing entries</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>incorrect syntax</secondary>
</indexterm><para>Client library routines contain compiled-in default entries that are
used if an entry in the <filename>nsswitch.conf</filename> file is either
missing or syntactically incorrect. These entries are the same as the switch
file's defaults.</para><para>The name service switch assumes that the table and source names are
spelled correctly. If you misspell a table or source name, the switch uses
default values.</para>
</sect3><sect3 id="a12swit-5"><title><literal>Auto_home</literal> and <literal>Auto_master</literal></title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>Auto_home table</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>Auto_master table</secondary>
</indexterm><indexterm><primary><filename>auto_master</filename> table</primary><secondary><filename>nsswitch.conf</filename> file and</secondary>
</indexterm><indexterm><primary><filename>auto_home</filename> table</primary><secondary><filename>nsswitch.conf</filename> file and</secondary>
</indexterm><para>The switch search criteria for the <filename>auto_home</filename> and <filename>auto_master</filename> tables and maps is combined into one category, which
is called <literal>automount</literal>.</para>
</sect3><sect3 id="a12swit-6"><title>Timezone and the Switch File</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>timezone table</secondary>
</indexterm><para><indexterm><primary><filename>timezone</filename> table</primary></indexterm>The <filename>timezone</filename> table does not use the switch,
so the table is not included in the switch file's list. </para>
</sect3>
</sect2><sect2 id="a12swit-8"><title>Comments in <filename>nsswitch.conf</filename> Files</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>comments in</secondary>
</indexterm><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary></indexterm>Any <filename>nsswitch.conf</filename> file line beginning with
a comment character (<literal>#</literal>) is interpreted as a comment line.
A comment line is ignored by routines that search the file.</para><para>Characters preceding a comment mark <emphasis>are</emphasis> interpreted
by routines that search the <filename>nsswitch.conf</filename> file. Characters
to the right of the comment mark are interpreted as comments and ignored.</para><table frame="topbot" id="a12swit-tbl-9"><title>Switch File Comment Examples</title><tgroup cols="2" colsep="0" rowsep="1"><colspec colname="column1" colwidth="119*"/><colspec colname="column2" colwidth="277*"/><thead><row><entry align="left" valign="bottom"><para>Type of Line</para>
</entry><entry align="left" valign="bottom"><para>Example</para>
</entry>
</row>
</thead><tbody><row><entry align="left" valign="bottom"><para>Comment line.</para>
</entry><entry align="left" valign="bottom"><para># hosts: nisplus [NOTFOUND=return] files</para>
</entry>
</row><row><entry align="left" valign="bottom"><para>Interpreted line.</para>
</entry><entry align="left" valign="bottom"><para>hosts: nisplus [NOTFOUND=return] file</para>
</entry>
</row><row><entry align="left" valign="top"><para>Partially interpreted line. The <literal>files</literal> element is
not interpreted.</para>
</entry><entry align="left" valign="top"><para>hosts: nisplus [NOTFOUND=return] # files</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2><sect2 id="a12swit-10"><title>Keyserver and <literal>publickey</literal> Entry
in the Switch File</title><caution><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><literal>keyserver</literal> entry</secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><literal>publickey</literal> entry</secondary></indexterm><indexterm><primary>keyserver</primary><secondary><filename>nsswitch.conf</filename> file and</secondary></indexterm>You
must restart the keyserver after you make a change to <filename>nsswitch.conf</filename>.</para>
</caution><para>The keyserver reads the <literal>publickey</literal> entry in the name
service switch configuration file only when the keyserver is started. If you
change the switch configuration file, the keyserver does not register the
changes until the keyserver is restarted.<literal></literal> </para>
</sect2>
</sect1><sect1 id="a12swit-22067"><title>The <filename>nsswitch.conf</filename> Template
Files</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>templates</secondary>
</indexterm><para>Four switch template files are provided with the Solaris system to accommodate
different naming services. Each file provides a different default set of information
sources.</para><para>The four template files are the following.</para><itemizedlist><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><filename>nsswitch.files</filename> file and</secondary></indexterm><emphasis>LDAP template file</emphasis>. The <filename>nsswitch.ldap</filename> configuration
file specifies the LDAP directory as the primary source of information for
the machine.</para><note><para>In order to use LDAP naming services, you must also properly configure
all LDAP client machines, in addition to modifying the <filename>nsswitch.conf</filename>.
See <olink targetptr="clientsetup-1" remap="internal">Chapter&nbsp;12, Setting Up LDAP Clients
(Tasks)</olink> for more information.</para>
</note>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><filename>nsswitch.nisplus</filename> file</secondary></indexterm><emphasis>NIS+ template file</emphasis>. The <filename>nsswitch.nisplus</filename> configuration
file specifies NIS+ as the primary source for all information except <literal>passwd</literal>, <literal>group</literal>, <literal>automount</literal>, and <filename>aliases</filename>. For those four files, the primary source is local  <filename>/etc</filename> files. The secondary source is an NIS+ table. The <returnvalue>[NOTFOUND=return]</returnvalue> search criterion instructs the switch to stop searching the
NIS+ tables if the switch gets  a &ldquo;No such entry&rdquo; message. The
switch searches through local files only if the NIS+ server is unavailable.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><filename>nsswitch.nis</filename> file</secondary></indexterm><emphasis>NIS template file</emphasis>. The <filename>nsswitch.nis</filename> configuration
file is almost identical to the NIS+ configuration file, except that NIS file
specifies NIS maps in place of NIS+ tables. Because the search order for passwd
and group is <literal>files nis</literal>, you don't need to place the + entry
in the  <filename>/etc/passwd</filename> and <filename>/etc/group</filename> files.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><filename>nsswitch.files</filename> file</secondary></indexterm><emphasis>Files template file</emphasis>. The <filename>nsswitch.files</filename> configuration
file specifies local <filename>/etc</filename> files as the only source of
information for the machine. There is no &ldquo;files&rdquo; source for <literal>netgroup</literal>, so the client does not use that entry in the switch file.</para>
</listitem>
</itemizedlist><para>Copy the template file that most closely meets your requirements to
the <filename>nsswitch.conf</filename> configuration file and then modify
the file as needed.</para><para>For example, to use the LDAP template file, you would type the following
command.</para><screen>mymachine# <userinput>cp /etc/nsswitch.ldap /etc/nsswitch.conf</userinput></screen><sect2 id="a12swit-11"><title>The Default Switch Template Files</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>default template files</secondary>
</indexterm><para>The following four switch files are supplied with the Solaris product.</para><example id="a12swit-ex-7"><title>NIS+ Switch File Template: <filename>nsswitch.nisplus</filename></title><screen>#
#
# /etc/nsswitch.nisplus:
#
#
# An example file that could be copied over to /etc/nsswitch.conf;
# it uses NIS+ (NIS Version 3) in conjunction with files.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
 
# the following two lines obviate the "+" entry in /etc/passwd 
# and /etc/group.
passwd: files nisplus
group: files nisplus
# consult /etc "files" only if nisplus is down. 
hosts: nisplus [NOTFOUND=return] files
# Uncomment the following line, and comment out the above, to use 
# both DNS and NIS+. You must also set up the /etc/resolv.conf 
# file for DNS name server lookup. See resolv.conf(4).
# hosts: nisplus dns [NOTFOUND=return] files
services: nisplus [NOTFOUND=return] files
networks: nisplus [NOTFOUND=return] files
protocols: nisplus [NOTFOUND=return] files
rpc: nisplus [NOTFOUND=return] files
ethers: nisplus [NOTFOUND=return] files
netmasks: nisplus [NOTFOUND=return] files	
bootparams: nisplus [NOTFOUND=return] files
publickey: nisplus
netgroup: nisplus
automount: files nisplus
aliases: files nisplus
sendmailvars: files nisplus</screen>
</example><note><para>For the <literal>publickey</literal> entry, the <literal>nisplus</literal> value
must be first in the list of values. For example, <literal>publickey: nisplus
files</literal> is the correct entry for an <filename>nsswitch.conf</filename> file
that multiple NIS+ domains consult.</para>
</note><example id="a12swit-ex-8"><title>NIS Switch File Template</title><screen>#
# /etc/nsswitch.nis:
#
# An example file that could be copied over to /etc/nsswitch.conf;
# it uses NIS (YP) in conjunction with files.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
#
# the following two lines obviate the "+" entry in /etc/passwd
# and /etc/group.
passwd: files nis
group: files nis
# consult /etc "files" only if nis is down. 
hosts: nis [NOTFOUND=return] files
networks: nis [NOTFOUND=return] files
protocols: nis [NOTFOUND=return] files
rpc: nis [NOTFOUND=return] files
ethers: nis [NOTFOUND=return] files
netmasks: nis [NOTFOUND=return] files	
bootparams: nis [NOTFOUND=return] files
publickey: nis [NOTFOUND=return] files
netgroup: nis
automount: files nis
aliases: files nis
# for efficient getservbyname() avoid nis
services: files nis
sendmailvars: files</screen>
</example><example id="a12swit-ex-2"><title>Files Switch File Template</title><screen>#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf;
# it does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet"
# transports.
passwd: files
group: files
hosts: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files	
bootparams: files
publickey: files
# At present there isn't a 'files' back end for netgroup;
# the system will figure it out pretty quickly, and will notuse
# netgroups at all.
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files</screen>
</example><example id="a12swit-ex-10"><title>LDAP Switch File Template</title><screen>#
# /etc/nsswitch.ldap:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# uses LDAP in conjunction with files.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

# the following two lines obviate the "+" entry in /etc/passwd 
and /etc/group.
passwd:     files ldap
group:      files ldap

hosts:      ldap [NOTFOUND=return] files

networks:   ldap [NOTFOUND=return] files
protocols:  ldap [NOTFOUND=return] files
rpc:        ldap [NOTFOUND=return] files
ethers:     ldap [NOTFOUND=return] files
netmasks:   ldap [NOTFOUND=return] files
bootparams: ldap [NOTFOUND=return] files
publickey:  ldap [NOTFOUND=return] files

netgroup:   ldap

automount:  files ldap
aliases:    files ldap

# for efficient getservbyname() avoid ldap
services:   files ldap
sendmailvars:   files</screen>
</example>
</sect2><sect2 id="a12swit-12"><title>The <filename>nsswitch.conf</filename> File</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>default file</secondary>
</indexterm><para>The default <filename>nsswitch.conf</filename> file that is installed
with the Solaris software is determined by which naming service you select
during the installation process. Each line identifies a particular type of
network information, such as host, password, and group, along with the information
source, such as NIS+ tables, NIS maps, the DNS hosts table, or local  <filename>/etc</filename>. When you chose a naming service, the switch template file for
that service is copied to create the new <filename>nsswitch.conf</filename> file.
For example, if you choose NIS+, the <filename>nsswitch.nisplus</filename> file
is copied to create a new <filename>nsswitch.conf</filename> file.</para><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>templates</secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>default files</secondary></indexterm>An <filename>nsswitch.conf</filename> file is automatically loaded into every machine's <filename>/etc</filename> directory by the Solaris 9 release software, along with the
following alternate (template) versions.</para><itemizedlist><listitem><para><indexterm><primary><filename>/etc/nsswitch.nisplus</filename> file</primary></indexterm><indexterm><primary><filename>nsswitch.nisplus</filename> file</primary></indexterm><filename>/etc/nsswitch.nisplus</filename></para>
</listitem><listitem><para><indexterm><primary><filename>/etc/nsswitch.nis</filename> file</primary></indexterm><indexterm><primary><filename>nsswitch.nis</filename> file</primary></indexterm><filename>/etc/nsswitch.nis</filename></para>
</listitem><listitem><para><indexterm><primary><filename>/etc/nsswitch.files</filename> file</primary></indexterm><indexterm><primary><filename>nsswitch.files</filename> file</primary></indexterm><filename>/etc/nsswitch.files</filename></para>
</listitem><listitem><para><indexterm><primary><filename>/etc/nsswitch.ldap</filename> file</primary></indexterm><indexterm><primary><filename>nsswitch.ldap</filename> file</primary></indexterm><filename>/etc/nsswitch.ldap</filename></para>
</listitem>
</itemizedlist><para><indexterm><primary>setup</primary><secondary>switch files</secondary></indexterm>These alternate template files contain the default switch configurations
used by the NIS+ and NIS services, local files, and LDAP. No default file
is provided for DNS, but you can edit any of these files to use DNS. When
the Solaris software is first installed on a machine, the installer selects
the machine's default naming service. During installation, the corresponding
template file is copied to <filename>/etc/nsswitch.conf</filename>. For example,
for a machine client using  NIS+, the installation process copies <filename>nsswitch.nisplus</filename>  to <filename>nsswitch.conf</filename>.</para><para>If your network is connected to the Internet and users must access Internet
hosts using DNS, you must enable DNS forwarding.</para><para>Unless you have an unusual namespace, the default template file as copied
to <filename>nsswitch.conf</filename> should be sufficient for normal operation.</para>
</sect2>
</sect1><sect1 id="c8switch-18904"><title>Selecting a Different Configuration File</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>choosing a file</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>installation of</secondary>
</indexterm><para>When you change a machine's naming service, you need to modify that
machine's switch file accordingly. For example, if you change a machine's
naming service from NIS to NIS+, you need to install a switch file appropriate
for NIS+. You change switch files by copying the appropriate template file
to <filename>nsswitch.conf</filename>.</para><para>If you are installing NIS+ on a machine using the NIS+ installation
scripts, the NIS+ template script is copied to <filename>nsswitch.conf</filename> for
you. In this case, you do not have to configure the switch file unless you
want to customize.</para><para>Before proceeding to change switch files, make sure the sources listed
in the file are properly set up. In other words, if you are going to select
the NIS+ version, the client must eventually have access to NIS+ service.
If you select the local files version, those files must be properly set up
on the client.</para><task id="c8switch-2"><title>How to Modify the Name Service Switch</title><tasksummary><para>To change to a switch file, follow these steps.</para><note><para>In order to use LDAP naming services, you must also properly configure
all LDAP client machines, in addition to modifying the <filename>nsswitch.conf</filename>.
See <olink targetptr="clientsetup-1" remap="internal">Chapter&nbsp;12, Setting Up LDAP Clients
(Tasks)</olink> for more information.</para>
</note>
</tasksummary><procedure><step id="c8switch-step-3"><para>Become superuser or assume an equivalent
role.</para><para>Roles contain authorizations and privileged commands. For
more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="c8switch-step-4"><para><indexterm><primary><filename>/etc/nsswitch.conf</filename></primary><secondary>modifying the switch</secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>modifying the switch</secondary></indexterm>Copy the appropriate alternate file for
the machine's naming service over the <filename>nsswitch.conf</filename> file.</para><para><emphasis>NIS+ Version</emphasis> (done automatically for you by NIS+
scripts)</para><screen>client1# <userinput>cd /etc</userinput>
client1# <userinput>cp nsswitch.nisplus nsswitch.conf</userinput></screen><para><emphasis>NIS Version</emphasis></para><screen>client1# <userinput>cd /etc</userinput>
client1# <userinput>cp nsswitch.nis nsswitch.conf</userinput></screen><para><emphasis>Local</emphasis> <filename>/etc</filename> <emphasis>Files
Version</emphasis></para><screen>client1# <userinput>cd /etc</userinput>
client1# <userinput>cp nsswitch.files nsswitch.conf</userinput></screen>
</step><step id="c8switch-step-5"><para>Reboot the machine.</para><para>The <command>nscd</command> daemon caches switch information.  See the <olink targetdoc="group-refman" targetptr="nscd-1m" remap="external"><citerefentry><refentrytitle>nscd</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for information.</para><para><indexterm><primary><command>nscd</command> daemon</primary></indexterm><indexterm><primary>daemons</primary><secondary>nscd</secondary></indexterm><indexterm><primary><filename>/etc/nsswitch.conf</filename></primary><secondary><command>nscd</command> daemon and</secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><command>nscd</command> daemon and</secondary></indexterm>Some library routines do not periodically check the <filename>nsswitch.conf</filename>  file to see whether the file has been changed. You must reboot
the machine to make sure that the daemon and those routines have the latest
information in the file.</para>
</step>
</procedure>
</task>
</sect1><sect1 id="a12swit-66520"><title>DNS and Internet Access</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>DNS and</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>Internet access</secondary>
</indexterm><indexterm><primary>Internet</primary><secondary><filename>nsswitch.conf</filename> file</secondary>
</indexterm><indexterm><primary>DNS</primary><secondary><filename>nsswitch.conf</filename> file</secondary>
</indexterm><para>The <filename>nsswitch.conf</filename> file also controls DNS forwarding
for clients as described in the following subsections. DNS forwarding grants
Internet access to clients. For information on how to set DNS forwarding for
NIS and NIS+, see <olink targetdoc="sysadv7" remap="external"><citetitle remap="book">System Administration Guide: Naming and Directory Services (NIS+)</citetitle></olink>.</para>
</sect1><sect1 id="a12swit-7"><title>IPv6 and Solaris Naming Services</title><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>IPv6 and</secondary>
</indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>Internet access</secondary>
</indexterm><indexterm><primary>Internet</primary><secondary><filename>nsswitch.conf</filename> file</secondary>
</indexterm><indexterm><primary>IPv6</primary><secondary><filename>nsswitch.conf</filename> file</secondary>
</indexterm><para>NIS, NIS+ and LDAP support storing IPv6 data, as well as using IPv6
transports for protocol traffic. Beginning with BIND version 8.3.3, DNS on
Solaris supports the use of IPv6 transports on the client side. As of BIND
version 8.4.2, DNS provides a complete client-server solution over IPv6 networks
on Solaris.</para><para>The <filename>nsswitch.conf</filename> file controls search criteria
for IPv6 addresses. IPv6 increases the IP address size from 32 bits to 128
bits to support more levels of addressing hierarchy. A larger address size
provides a greater number of addressable nodes. For more information about
IPv6, its configuration and implementation, see <olink targetdoc="sysadv3" remap="external"><citetitle remap="book">System Administration Guide: IP Services</citetitle></olink>.</para><para>Use the new <literal>ipnodes</literal> source for IPv6 addresses. The <filename>/etc/inet/ipnodes</filename> file stores both IPv4 and IPv6 addresses. The <filename>/etc/inet/ipnodes</filename> file uses the same format convention as the <filename>/etc/hosts</filename> file.</para><para>IPv6 aware naming services use the new <literal>ipnodes</literal> source
for its search forwarding. For instance, if LDAP is aware of IPv6 addresses,
specify the following.</para><screen>ipnodes: ldap [NOTFOUND=return] files</screen><caution><para>Potential delay issues:</para><itemizedlist><listitem><para><literal>ipnodes</literal> defaults to <literal>files</literal>.
During the transition from IPv4 to IPv6, where all naming services are not
aware of IPv6 addresses, accept the <literal>files</literal> default. Otherwise,
unnecessary delays, such as boot timing delays, might result during the resolution
of addresses.</para>
</listitem><listitem><para>An application searches all <literal>ipnodes</literal> databases
for IPv4 addresses before searching for IPv4 addresses in the <literal>hosts</literal> databases.
Before specifying <literal>ipnodes</literal>, consider the inherent delay
of searching both databases for IPv4 addresses.</para>
</listitem>
</itemizedlist>
</caution>
</sect1><sect1 id="a12swit-11308"><title>Ensuring Compatibility With +/- Syntax</title><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>+/- Syntax</secondary></indexterm><indexterm><primary>+/- Syntax</primary><secondary><filename>nsswitch.conf</filename> file</secondary></indexterm>If
+/- is used in <filename>/etc/passwd</filename>, <filename>/etc/shadow,</filename> and <filename>/etc/group</filename> files, you need to modify the <filename>nsswitch.conf</filename> file
to insure compatibility.</para><itemizedlist><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><literal>compat</literal></secondary></indexterm><indexterm><primary>+/- Syntax</primary><secondary><literal>compat</literal></secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><literal>passwd_compat</literal></secondary></indexterm><indexterm><primary>+/- Syntax</primary><secondary><literal>passwd_compat</literal></secondary></indexterm><emphasis>NIS+</emphasis>. To provide +/- semantics with NIS+, change the <literal>passwd</literal> and <literal>groups</literal> sources to <literal>compat</literal>. Then,  add a <literal>passwd_compat:
nisplus</literal> entry to the <filename>nsswitch.conf</filename> file after
the <literal>passwd</literal> or <literal>group</literal> entry as shown below.</para><screen>passwd: compat
passwd_compat: nisplus
group: compat
group_compat: nisplus</screen><para><indexterm><primary><filename>/etc</filename> files</primary></indexterm>The
above specifies that client routines obtain their network information from <filename>/etc</filename> files and NIS+ tables as indicated by the <literal>+/-</literal> entries
in the files.</para>
</listitem><listitem><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary><literal>compat</literal></secondary></indexterm><indexterm><primary>+/- Syntax</primary><secondary><literal>compat</literal></secondary></indexterm><emphasis>NIS</emphasis>. To provide the same syntax as in the Solaris 4.x release,
change the <literal>passwd</literal> and <literal>groups</literal> sources
to <literal>compat</literal>.</para><screen>passwd: compat
group: compat</screen><para>Specifies the <filename>/etc</filename> files and NIS maps as indicated
by the +/- entries in the files.</para><note><para><indexterm><primary><command>ypcat</command></primary></indexterm>Users
working on a client machine being served by an NIS+ server running in NIS
compatibility mode cannot run <command>ypcat</command> on the <literal>netgroup</literal> table.
Doing so gives you results as if the table were empty even if the table has
entries. </para>
</note>
</listitem>
</itemizedlist>
</sect1><sect1 id="a12swit-27155"><title>The Switch File and Password Information</title><para>It is possible to include and access password information in multiple
repositories, such as <literal>files</literal> and <literal>nisplus</literal>.
You can use the <filename>nsswitch.conf</filename> file to establish the lookup
order for that information.</para><caution><para><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>password data and</secondary></indexterm><indexterm><primary>password data</primary><secondary><filename>nsswitch.conf</filename> file</secondary></indexterm><literal>files</literal> must be the first source in the <filename>nsswitch.conf</filename> file for <literal>passwd</literal> information.</para>
</caution><para>In an NIS+ environment, the <literal>passwd</literal> line of the <filename>nsswitch.conf</filename> file should list the repositories in the following
order.</para><screen>passwd: files nisplus</screen><para>In an NIS environment, the <literal>passwd</literal> line of the <filename>nsswitch.conf</filename> file should list the repositories in the following
order.</para><screen>passwd: files nis</screen><tip><para><indexterm><primary><command>password</command> <option>r</option> command</primary></indexterm><indexterm><primary>repositories</primary><secondary>using multiple</secondary></indexterm><indexterm><primary>repository</primary><secondary>updating</secondary></indexterm><indexterm><primary><filename>nsswitch.conf</filename> file</primary><secondary>updating</secondary></indexterm>Listing <literal>files</literal> first allows <literal>root</literal> to log in, under most
circumstances, even when the system encounters some network or naming services
issues.</para>
</tip><para>Maintaining multiple repositories <emphasis>for the same user</emphasis> is
not recommended. By maintaining centralized password management in a single
repository for each user, you reduce the possibilities of confusion and error.
If you choose to maintain multiple repositories per user, update password
information by using the <command>passwd</command> <option>r</option> command.</para><screen><command>passwd</command> <option>r</option> <replaceable>repository</replaceable></screen><para>If no repository is specified with the <option>r</option> option, <command>passwd</command> updates the repositories listed in <filename>nsswitch.conf</filename> in
reverse order.</para>
</sect1>
</chapter><?Pub *0000047829 0?>