Inom
Hitta mer dokumentation
Supportresurser som ingår
| Ladda ner denna bok i PDF
Understanding the Name Service Switch
5
- The name service switch, referred to as the "switch," is not really part of NIS+, but it enables NIS+ clients (actually, clients of getXXbyYY() routines) to obtain their network information from one or more of these sources: NIS+ tables, NIS maps, the DNS hosts table, and local /etc files. This chapter describes the switch and what it can do. It has four sections
-
About the Name Service Switch
- An NIS+ client can obtain its information from one or more of the switch's sources in place of, or in addition, to NIS+ tables. For example, an NIS+ client could obtain its hosts information from an NIS+ table, its group information from NIS maps, and its password information from a local /etc file. Plus, it could specify the conditions under which the switch must use each source (see "Search Criteria" on page 65).
- These choices are specified in a special configuration file called nsswitch.conf. This file is automatically loaded into every workstation's /etc directory by the Solaris 2.4 software, along with three alternate versions:
-
-
-
/etc/nsswitch.nis
-
/etc/nsswitch.files
- These alternate files contain the default switch configurations used by the NIS+ service, NIS, and local files. (They are described later in this section.) No default file is provided for DNS, but you can edit any of these files to use DNS.
- When the Solaris 2.4 software is first installed on a workstation, the installer must select the workstation's default naming service: NIS+, NIS, or local files. During the installation, the corresponding configuration file is copied into the /etc/nsswitch.conf file.
- You can change the sources of information used by an NIS+ client by creating your own customized configuration file and copying it over /etc/nsswitch.conf. Its syntax is described below, and instructions are provided in Name Services Administration Guide.
Format of the nsswitch.conf File
- The nsswitch.conf file is essentially a list of 15 types of information and their sources, not necessarily in this order:
-
aliases: source(s)
bootparams: source(s)
ethers: source(s)
group: source(s)
hosts: source(s)
netgroup: source(s)
netmasks: source(s)
networks: source(s)
passwd: (includes shadow) source(s)
protocols: source(s)
publickey: source
rpc: source(s)
services: source(s)
automount: source(s)
sendmailvars source(s)
|
- The information for the Auto_home and Auto_master tables is combined into one category, called "automount." The timezone table does not use the switch, so it is not included in the list. Possible sources are listed in Table 5-1:
-
Table 5-1
| Source | Description |
| files | A local file stored in the client's /etc directory (for example, /etc/passwd) |
| nisplus | An NIS+ table |
| nis | An NIS map |
| compat | Only for the Password and Group entries, supports the old-style "+" or "-" syntax in the /etc/passwd, /etc/shadow, and /etc/group files. |
| dns | DNS, but only for the hosts entry. |
- If an information type has only one source, the switch searches for the information in that source only. (If it does not find the information, it stops searching and returns a status message. The status message is passed to the library routine that requested the information. What the routine does with the status message varies from routine to routine.)
- If a table has more than one source, the switch starts by searching for the information in the first source. If it does not find the information there, it tries the next source. The switch continues searching through the sources until it has tried them all.
- If the switch still does not find the information, it stops searching and returns a status message. However, you can specify a different course of action, such as continuing to search for the information, done with search criteria.
-
Search Criteria The switch searches through the sources one at a time. If it finds the information it is looking for in the first source, it returns a successful status message and passes the information to the library routine that asked for it. If the switch does not find the information, it returns one of three unsuccessful
- status messages, depending on the reason for not finding the information, and moves to the next source. The four possible status messages are listed in Table 5-2:
-
Table 5-2
| Status | Meaning |
| SUCCESS | The requested entry was found in the source |
| UNAVAIL | The source is not responding or is unavailable |
| NOTFOUND | The source responded with "No such entry" |
| TRYAGAIN | The source is busy; it might respond next time |
- You can instruct the switch to respond to status messages with either of these two actions shown in Table 5-3:
-
Table 5-3
| Action | Meaning |
| return | Stop looking for the information |
| continue | Try the next source, if there is one |
-
Default Search Criteria The switch's default search criteria are the same for every source. Described in terms of the status messages listed above, they are:
-
- SUCCESS=return
- UNAVAIL=continue
- NOTFOUND=continue
- TRYAGAIN=continue
- You can change the default search criteria for any source, using the STATUS=action syntax shown above. For example:
-
hosts: nis
networks: nis [NOTFOUND=return] files
protocols: nis [NOTFOUND=return] files
|
- In the second line of the example above, when the switch searches for information in NIS maps and gets a NOTFOUND status message, instead of searching through the second source, it stops looking. It would search through files only if the NIS service was unavailable.
-
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 default nsswitch.conf file.
- 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 the default values instead.
-
Default nsswitch.conf File The default nsswitch.conf file shipped with Solaris 2.4 is actually a copy of the nsswitch.nis file, described below. You can change it to the NIS+ version by copying the nsswitch.nisplus file over the /etc/nswitch.conf file.
- The switch provides three alternate configuration files in addition to the default /etc/nsswitch.conf file. Each is described below.
nsswitch.nisplus File
- The nsswitch.nisplus configuration file specifies NIS+ as the primary source for all information except passwd, group, automount, and aliases. For those 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. Here is a copy of the file with all the comments stripped out:
-
passwd: files nisplus
group: files nisplus
hosts: nisplus [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
|
DNS Forwarding for NIS+ Clients
- NIS+ clients do not have implicit DNS forwarding capabilities like NIS clients do. Instead, they take advantage of the switch. To provide DNS forwarding capabilities to an NIS+ client, change its hosts entry to:
-
-
hosts: nisplus dns [NOTFOUND=return] files
The nsswitch.nis 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.
-
passwd: files nis
group: files nis
hosts: nis [NOTFOUND=return] files
services: 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
|
- 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.
DNS Forwarding for NIS Clients
- If an NIS client is using the DNS forwarding capability of a NIS-compatible NIS+ server, its nsswitch.conf file should not have the following syntax for the hosts file:
-
-
hosts: nis dns files
- Since DNS forwarding automatically forwards host requests to DNS, the syntax shown above would cause the NIS+ server to forward unsuccessful requests to the DNS servers twice, impacting performance.
- To take best advantage of DNS forwarding, use the default syntax for the nsswitch.nis file, as shown in the box above.
The nsswitch.files File
- The nsswitch.files configuration file specifies local /etc files as the only source of information for the workstation.
-
passwd: files
group: files
hosts: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
netgroup: files
automount: files
aliases: files
services: files
|
- There is no "files" source for netgroup, so the client simply won't use it.
|
|