93
93
The NSS module is implemented in the nss directory. The functions are split
94
into files according to the database they support. Functions look like:
94
into files according to the database they support. The files support multiple
97
The NSS interface is specific to the C library that is used. The original
98
implementation was for the GNU C Library but now also includes an
99
implementation for Solaris' C Library and has some support for FreeBSD.
104
Function definitions for glibc look like:
96
106
_nss_ldap_FUNCTION_r(...)
97
107
This function opens the connection to the nslcd (with a time-out), builds
99
109
waiting for an answer (again with a time-out)
101
111
The complete list of exported functions can be found in exports.linux and
102
prototypes.h. The NSS interface seems to be fairly libc-specific and is
103
currently tuned towards GNU Libc, although FreeBSD has a port based on this
106
114
Currently a number of macros are used to build most of the function bodies for
107
115
these functions. Part of this is defined in the common/nslcd-prot.h file and
108
116
the NSS-specific stuff is in nss/common.h.
118
For memory management, the general mechanism that is expected to be used is
119
to return NSS_STATUS_TRYAGAIN and set errno to ERANGE. This causes glibc to
120
retry the request with a larger buffer.
110
122
Some useful links:
111
123
http://www.gnu.org/software/libc/manual/html_node/index.html
125
Solaris C Library notes
126
-----------------------
128
The Solaris C library uses a different mechanism. For each map a back-end
129
object is allocated per thread which is used to do queries. The object is
130
created with a constructor (e.g. _nss_ldap_passwd_constr()) that returns a
131
back-end that contains a list of function pointer to lookup methods and a
134
A buffer is passed with every request but a local buffer that is stored in the
135
back-end can presumably also be created.
137
Earlier versions of Solaris expected the NSS functions to return the binary
138
representation of the lookups (e.g. struct passwd) but later versions expect a
139
string representation of the data to be returned (just like a single line out
140
of /etc/passwd was read).
142
Source and documentation pointers for Solaris NSS:
143
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/nsswitch/
144
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/nss_common.h
145
http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/nss_dbdefs.h
147
FreeBSD C Libarary notes
148
------------------------
150
The FreeBSD C library seems to have support for exposing GNU C Library NSS
151
module functions through a wrapper function. This makes it very easy to
152
implement NSS support on FreeBSD.
154
Pointers for more documentation on this is welcome. Some information is
156
http://nixdoc.net/man-pages/FreeBSD/man3/nsdispatch.3.html
157
ftp://ftp8.tw.freebsd.org/pub/branches/-current/src/include/nss.h