Next: The Interface of the Function in NSS Modules, Previous: NSS Module Internals, Up: NSS Module Internals [Contents][Index]
The name of each function consists of various parts:
_nss_service_function
service of course corresponds to the name of the module this
function is found in.4 The function part is derived
from the interface function in the C library itself. If the user calls
the function gethostbyname
and the service used is files
the function
_nss_files_gethostbyname_r
in the module
libnss_files.so.2
is used. You see, what is explained above in not the whole truth. In
fact the NSS modules only contain reentrant versions of the lookup
functions. I.e., if the user would call the gethostbyname_r
function this also would end in the above function. For all user
interface functions the C library maps this call to a call to the
reentrant function. For reentrant functions this is trivial since the
interface is (nearly) the same. For the non-reentrant version the
library keeps internal buffers which are used to replace the user
supplied buffer.
I.e., the reentrant functions can have counterparts. No service
module is forced to have functions for all databases and all kinds to
access them. If a function is not available it is simply treated as if
the function would return unavail
(see Actions in the NSS configuration).
The file name libnss_files.so.2 would be on a Solaris 2 system nss_files.so.2. This is the difference mentioned above. Sun’s NSS modules are usable as modules which get indirectly loaded only.
The NSS modules in the GNU C Library are prepared to be used as normal libraries themselves. This is not true at the moment, though. However, the organization of the name space in the modules does not make it impossible like it is for Solaris. Now you can see why the modules are still libraries.5
Now you might ask why this information is duplicated. The answer is that we want to make it possible to link directly with these shared objects.
There is a second explanation: we were too lazy to change the Makefiles to allow the generation of shared objects not starting with lib but don’t tell this to anybody.
Next: The Interface of the Function in NSS Modules, Previous: NSS Module Internals, Up: NSS Module Internals [Contents][Index]