Switch Action Options
You can instruct the switch to respond to status messages with either of these two actions shown in the following table.
Table 1-3 Responses to Switch Status Messages
Stop looking for the information.
Try the next source, if there is one.
Default Search Criteria
The combination of nsswitch.conf file status message and action option determines what the routine does at each step. This combination of status and action is called the search criteria.
Because these are the default search criteria, they are assumed. That is, you do not have to explicitly specify them in the switch file. You can change these default search criteria by explicitly specifying some other criteria using the STATUS=action syntax show above. For example, the default action for a NOTFOUND condition is to continue the search to the next source. To specify that for a particular type of information, such as networks, the search is to halt on a NOTFOUND condition, you would edit the networks line of the switch file to read:
networks: nis [NOTFOUND=return] files
The networks: nis [NOTFOUND=return] files line specifies a non-default criterion for the NOTFOUND status. Non-default criteria are delimited by square brackets.
In this example, the search routine behaves as follows:
If the networks map is available and contains the needed information, the routine returns with a SUCCESS status message.
If the networks map is not available, the routine returns with an UNAVAIL status message and by default continues on to search the appropriate /etc file.
If the networks map is available and found, but it does not contain the needed information, the routine returns with a NOTFOUND message. But, instead of continuing on to search the appropriate /etc file, which would be the default behavior, the routine stops searching.
If the networks map is busy, the routine returns with an TRYAGAIN status message and by default continues on to search the appropriate /etc file.
What if the Syntax is Wrong?
Client library routines contain compiled-in default entries that are used if an entry in the nsswitch.conf file is either missing or syntactically incorrect. These entries are the same as the switch file's defaults.
The name service switch assumes that the spelling of table and source names is correct. If you misspell a table or source name, the switch uses default values.
Auto_home and Auto_master
The switch search criteria for the auto_home and auto_master tables and maps is combined into one category called automount.
Timezone and the Switch File
Comments in nsswitch.conf Files
When a comment character (#) is included in the middle of the line, characters preceding the comment mark are interpreted by routines that search the nsswitch.conf file. Characters to the right of the comment mark are interpreted as comments and ignored.
Table 1-4 Switch File Comment Examples
Type of Line
Comment line (not interpreted).
# hosts: nisplus [NOTFOUND=return] files
Fully interpreted line.
hosts: nisplus [NOTFOUND=return] file
Partially interpreted line (the files element not interpreted)
hosts: nisplus [NOTFOUND=return] # files
Keyserver and publickey Entry in the Switch File
Caution - You must restart the keyserver after you make a change to nsswitch.conf
The keyserver reads the publickey entry in the name service switch configuration file only when the keyserver is started. As a result, if you change the switch configuration file, the keyserver does not become aware of changes to the publickey entry until it is restarted.
The nsswitch.conf Template Files
Four nsswitch.conf template files are provided with the Solaris operating environment to accommodate different naming services. Each of them provides a different default set of primary and subsequent information sources.
The four template files are:
NIS+ template file. The nsswitch.nisplus configuration file specifies NIS+ as the primary source for all information except passwd, group, automount, and aliases. For those four files, the primary source is local /etc files and the secondary source is an NIS+ table. The [NOTFOUND=return] search criterion instructs the switch to stop searching the NIS+ tables if it receives a "No such entry" message from them. It searches through local files only if the NIS+ server is unavailable.
NIS template file. The nsswitch.nis configuration file is almost identical to the NIS+ configuration file, except that it specifies NIS maps in place of NIS+ tables. Because the search order for passwd and group is files nis, you don't need to place the + entry in the /etc/passwd and /etc/group files.
Files template file. The nsswitch.files configuration file specifies local /etc files as the only source of information for the machine. There is no "files" source for netgroup, so the client will not use that entry in the switch file.
Copy the template file that most closely meets your requirements to thensswitch.conf configuration file and then modify the file as needed.
For example, to use the LDAP template file, you would type the following command:
mymachine# cp nsswitch.ldap nsswitch.conf
The Default Switch Template Files
Here are the four switch files supplied with Solaris operating environment:
Example 1-1 NIS+ Switch File Template (nsswitch.nisplus)
Example 1-2 NIS Switch File Template
Example 1-3 Files Switch File Template