Chapter 29. System Databases and Name Service Switch

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 GNU C Library contains a cleaner solution of this problem. It is designed after a method used by Sun Microsystems in the C library of Solaris 2. GNU C Library follows their name and calls this scheme Name Service Switch (NSS).

Though the interface might be similar to Sun's version there is no common code. We never saw any source code of Sun's implementation and so the internal interface is incompatible. This also manifests in the file names we use as we will see later.

NSS Basics

The basic idea is to put the implementation of the different services offered to access the databases in separate modules. This has some advantages:

  1. Contributors can add new services without adding them to GNU C Library.

  2. The modules can be updated separately.

  3. The C library image is smaller.

To fulfill the first goal above the ABI of the modules will be described below. For getting the implementation of a new service right it is important to understand how the functions in the modules get called. They are in no way designed to be used by the programmer directly. Instead the programmer should only use the documented and standardized functions to access the databases.

The databases available in the NSS are

aliases

Mail aliases

ethers

Ethernet numbers,

group

Groups of users, the section called “Group Database”.

hosts

Host names and numbers, the section called “Host Names”.

netgroup

Network wide list of host and users, the section called “Netgroup Database”.

networks

Network names and numbers, the section called “Networks Database ”.

protocols

Network protocols, the section called “Protocols Database”.

passwd

User passwords, the section called “User Database”.

rpc

Remote procedure call names and numbers,

services

Network services, the section called “The Services Database”.

shadow

Shadow user passwords,

There will be some more added later (automount, bootparams, netmasks, and publickey).