|
Home | Switchboard | Unix Administration | Red Hat | TCP/IP Networks | Neoliberalism | Toxic Managers |
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and bastardization of classic Unix |
|
The name service switch file determines which name services a system uses to search for information, and in which order the name services are searched. All Solaris systems use the /etc/nsswitch.conf file as the name service switch file. The nsswitch.conf file is loaded with the contents of a template file during the installation of the Solaris, depending on the name service that is selected.
|
The /etc/nsswitch.conf file includes a list of databases that are sources of information about IP addresses, users, and groups. Data for these can come from a variety of sources. For example, host names and host addresses, are located in the /etc/hosts file, NIS, NIS+, LDAP, or DNS. Each database has zero or more sources; the sources and their lookup order are specified in the /etc/nsswitch.conf file.
Note: The default name service during installation of the Solaris 9 is the /etc/nsswitch.nisplus template that configures the name service for NIS+.
The following example is the /etc/nsswitch.conf file configured to support the NIS name service using the /etc/nsswitch.nis template.
# /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
ipnodes: files... ... ...
There are five templates that are used during Solaris installation, or when you need to change name service:
There is an entry in the /etc/nsswitch.conf file for each database. Some typical examples of these entries are:
ipnodes: files
passwd: files nis
hosts: nis [NOTFOUND=return] files
There might be a single information source listed, in which case the search terminates if the information is not found. If two or more sources are listed, the first listed source is searched before moving on to the next listed source.
When multiple information sources are specified, it is sometimes necessary to define precisely the circumstances under which each source is searched. When a name service is referenced, the attempt to search this source can return one of the following status codes:
For each status code, two actions are possible. When the action is not explicitly specified, the default action is to continue the search using the next specified information source, as follows:
Examples:
ipnodes: files
In this example, the /etc/inet/ipnodes file is searched for the first entry that matches the requested host name. If no matches are found, an appropriate error is returned, and no further information sources are searched.
In this example, the appropriate files in the /etc directory are searched for the corresponding password entry. If the entry is not found, the NIS maps are searched for the entry. If no entry is found in the NIS maps, an appropriate error is returned, and no further information sources are searched.
hosts: nis [NOTFOUND=return] files
In this example, the NIS maps are searched for the entry. If the source (NIS) is not running, the system returns the status UNAVAIL, and continues to search the /etc/inet/hosts file. If the entry returns the status NOTFOUND, an appropriate error is returned, and the search is terminated without searching the /etc/inet/hosts file.
Various functions in the C Library need to be configured to work correctly in the local environment. Traditionally, this was done by using files (e.g., `/etc/passwd'), but other nameservices (like the Network Information Service (NIS) and the Domain Name Service (DNS)) became popular, and were hacked into the C library, usually with a fixed search order.
The Linux libc5 with NYS support and the GNU C Library 2.x (libc.so.6) contain a cleaner solution of this problem. It is designed after a method used by Sun Microsystems in the C library of Solaris 2. We follow their name and call this scheme "Name Service Switch" (NSS). The sources for the "databases" and their lookup order are specified in the /etc/nsswitch.conf file.
The following databases are available in the NSS:
- aliases
- Mail aliases, used by sendmail(8). Presently ignored.
- ethers
- Ethernet numbers.
- group
- Groups of users, used by getgrent(3) functions.
- hosts
- Host names and numbers, used by gethostbyname(3) and similar functions.
- netgroup
- Network wide list of hosts and users, used for access rules. C libraries before glibc 2.1 only support netgroups over NIS.
- network
- Network names and numbers, used by getnetent(3) functions.
- passwd
- User passwords, used by getpwent(3) functions.
- protocols
- Network protocols, used by getprotoent(3) functions.
- publickey
- Public and secret keys for Secure_RPC used by NFS and NIS+.
- rpc
- Remote procedure call names and numbers, used by getrpcbyname(3) and similar functions.
- services
- Network services, used by getservent(3) functions.
- shadow
- Shadow user passwords, used by getspnam(3).
An example /etc/nsswitch.conf (namely, the default used when /etc/nsswitch.conf is missing):
- passwd:
- compat
- group:
- compat
- shadow:
- compat
- hosts:
- dns [!UNAVAIL=return] files
- networks:
- nis [NOTFOUND=return] files
- ethers:
- nis [NOTFOUND=return] files
- protocols:
- nis [NOTFOUND=return] files
- rpc:
- nis [NOTFOUND=return] files
- services:
- nis [NOTFOUND=return] files
The first column is the database. The rest of the line specifies how the lookup process works. You can specify the way it works for each database individually.
The configuration specification for each database can contain two different items:
- * The service specification like `files', `db', or `nis'.
- * The reaction on lookup result like `[NOTFOUND=return]'.
For libc5 with NYS, the allowed service specifications are `files', `nis', and `nisplus'. For hosts, you could specify `dns' as extra service, for passwd and group `compat', but not for shadow.
For glibc, you must have a file called /lib/libnss_SERVICE.so.X for every SERVICE you are using. On a standard installation, you could use `files', `db', `nis', and `nisplus'. For hosts, you could specify `dns' as extra service, for passwd, group, and shadow `compat'. These services will not be used by libc5 with NYS. The version number X is 1 for glibc 2.0 and 2 for glibc 2.1.
The second item in the specification gives the user much finer control on the lookup process. Action items are placed between two service names and are written within brackets. The general form is
`[' ( `!'? STATUS `=' ACTION )+ `]'
where
- STATUS => success | notfound | unavail | tryagain
- ACTION => return | continue
The case of the keywords is insignificant. The STATUS values are the results of a call to a lookup function of a specific service. They mean:
- success
- No error occurred and the wanted entry is returned. The default action for this is `return'.
- notfound
- The lookup process works ok but the needed value was not found. The default action is `continue'.
- unavail
- The service is permanently unavailable. This can either mean the needed file is not available, or, for DNS, the server is not available or does not allow queries. The default action is `continue'.
- tryagain
- The service is temporarily unavailable. This could mean a file is locked or a server currently cannot accept more connections. The default action is `continue'.
Interaction with +/- syntax (compat mode)
Linux libc5 without NYS does not have the name service switch but does allow the user some policy control. In /etc/passwd you could have entries of the form +user or +@netgroup (include the specified user from the NIS passwd map), -user or -@netgroup (exclude the specified user), and + (include every user, except the excluded ones, from the NIS passwd map). Since most people only put a + at the end of /etc/passwd to include everything from NIS, the switch provides a faster alternative for this case (`passwd: files nis') which doesn't require the single + entry in /etc/passwd, /etc/group, and /etc/shadow. If this is not sufficient, the NSS `compat' service provides full +/- semantics. By default, the source is `nis', but this may be overriden by specifying `nisplus' as source for the pseudo-databases passwd_compat, group_compat and shadow_compat. This pseudo-databases are only available in GNU C Library.
A service named SERVICE is implemented by a shared object library named libnss_SERVICE.so.X that resides in /lib.
- /etc/nsswitch.conf configuration file
- /lib/libnss_compat.so.X
- implements `compat' source for glibc2
- /lib/libnss_db.so.X
- implements `db' source for glibc2
- /lib/libnss_dns.so.X
- implements `dns' source for glibc2
- /lib/libnss_files.so.X
- implements `files' source for glibc2
- /lib/libnss_hesiod.so.X
- implements `hesiod' source for glibc2
- /lib/libnss_nis.so.X
- implements `nis' source for glibc2
- /lib/libnss_nisplus.so.2
- implements `nisplus' source for glibc 2.1
NOTES
Within each process that uses nsswitch.conf, the entire file is read only once; if the file is later changed, the process will continue using the old configuration.
With Solaris, it isn't possible to link programs using the NSS Service statically. With Linux, this is no problem.
Society
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
Quotes
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Bulletin:
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
History:
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
Classic books:
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|
You can use PayPal to to buy a cup of coffee for authors of this site |
Disclaimer:
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.
Last modified: August 12, 2009