]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/nss.texi
Update.
[thirdparty/glibc.git] / manual / nss.texi
CommitLineData
7a68c94a 1@node Name Service Switch, Users and Groups, Job Control, Top
706074a5 2@chapter System Databases and Name Service Switch
7a68c94a 3@c %MENU% Accessing system databases
2c6fe0bd
UD
4@cindex Name Service Switch
5@cindex NSS
6d52618b 6@cindex databases
7a68c94a 7
706074a5
UD
8Various functions in the C Library need to be configured to work
9correctly in the local environment. Traditionally, this was done by
6952e59e 10using files (e.g., @file{/etc/passwd}), but other nameservices (like the
706074a5
UD
11Network Information Service (NIS) and the Domain Name Service (DNS))
12became popular, and were hacked into the C library, usually with a fixed
84384f5b 13search order (@pxref{frobnicate, , ,jargon, The Jargon File}).
706074a5
UD
14
15The GNU C Library contains a cleaner solution of this problem. It is
16designed after a method used by Sun Microsystems in the C library of
17@w{Solaris 2}. GNU C Library follows their name and calls this
18scheme @dfn{Name Service Switch} (NSS).
19
20Though the interface might be similar to Sun's version there is no
21common code. We never saw any source code of Sun's implementation and
6952e59e 22so the internal interface is incompatible. This also manifests in the
706074a5
UD
23file names we use as we will see later.
24
25
26@menu
27* NSS Basics:: What is this NSS good for.
28* NSS Configuration File:: Configuring NSS.
29* NSS Module Internals:: How does it work internally.
30* Extending NSS:: What to do to add services or databases.
31@end menu
32
33@node NSS Basics, NSS Configuration File, Name Service Switch, Name Service Switch
34@section NSS Basics
35
36The basic idea is to put the implementation of the different services
37offered to access the databases in separate modules. This has some
38advantages:
39
40@enumerate
41@item
42Contributors can add new services without adding them to GNU C Library.
43@item
44The modules can be updated separately.
45@item
46The C library image is smaller.
47@end enumerate
48
49To fulfill the first goal above the ABI of the modules will be described
50below. For getting the implementation of a new service right it is
51important to understand how the functions in the modules get called.
52They are in no way designed to be used by the programmer directly.
53Instead the programmer should only use the documented and standardized
54functions to access the databases.
55
56@noindent
57The databases available in the NSS are
58
59@cindex ethers
60@cindex group
61@cindex hosts
ba1ffaa1 62@cindex netgroup
b3a86ae1 63@cindex networks
706074a5
UD
64@cindex protocols
65@cindex passwd
66@cindex rpc
67@cindex services
68@cindex shadow
69@vtable @code
26dee9c4
UD
70@item aliases
71Mail aliases
72@comment @pxref{Mail Aliases}.
706074a5
UD
73@item ethers
74Ethernet numbers,
75@comment @pxref{Ethernet Numbers}.
76@item group
77Groups of users, @pxref{Group Database}.
78@item hosts
79Host names and numbers, @pxref{Host Names}.
ba1ffaa1
UD
80@item netgroup
81Network wide list of host and users, @pxref{Netgroup Database}.
b3a86ae1 82@item networks
706074a5
UD
83Network names and numbers, @pxref{Networks Database}.
84@item protocols
85Network protocols, @pxref{Protocols Database}.
86@item passwd
87User passwords, @pxref{User Database}.
88@item rpc
89Remote procedure call names and numbers,
90@comment @pxref{RPC Database}.
91@item services
92Network services, @pxref{Services Database}.
93@item shadow
94Shadow user passwords,
95@comment @pxref{Shadow Password Database}.
96@end vtable
97
98@noindent
26dee9c4
UD
99There will be some more added later (@code{automount}, @code{bootparams},
100@code{netmasks}, and @code{publickey}).
706074a5
UD
101
102@node NSS Configuration File, NSS Module Internals, NSS Basics, Name Service Switch
103@section The NSS Configuration File
104
105@cindex @file{/etc/nsswitch.conf}
106@cindex @file{nsswitch.conf}
107Somehow the NSS code must be told about the wishes of the user. For
108this reason there is the file @file{/etc/nsswitch.conf}. For each
109database this file contain a specification how the lookup process should
110work. The file could look like this:
111
112@example
113@include nsswitch.texi
114@end example
115
116The first column is the database as you can guess from the table above.
117The rest of the line specifies how the lookup process works. Please
118note that you specify the way it works for each database individually.
119This cannot be done with the old way of a monolithic implementation.
120
121The configuration specification for each database can contain two
122different items:
123
124@itemize @bullet
125@item
126the service specification like @code{files}, @code{db}, or @code{nis}.
127@item
26dee9c4 128the reaction on lookup result like @code{[NOTFOUND=return]}.
706074a5
UD
129@end itemize
130
131@menu
ba1ffaa1 132* Services in the NSS configuration:: Service names in the NSS configuration.
6d52618b 133* Actions in the NSS configuration:: React appropriately to the lookup result.
706074a5
UD
134* Notes on NSS Configuration File:: Things to take care about while
135 configuring NSS.
136@end menu
137
138@node Services in the NSS configuration, Actions in the NSS configuration, NSS Configuration File, NSS Configuration File
139@subsection Services in the NSS configuration File
140
141The above example file mentions four different services: @code{files},
142@code{db}, @code{nis}, and @code{nisplus}. This does not mean these
143services are available on all sites and it does also not mean these are
144all the services which will ever be available.
145
146In fact, these names are simply strings which the NSS code uses to find
147the implicitly addressed functions. The internal interface will be
148described later. Visible to the user are the modules which implement an
149individual service.
150
151Assume the service @var{name} shall be used for a lookup. The code for
152this service is implemented in a module called @file{libnss_@var{name}}.
153On a system supporting shared libraries this is in fact a shared library
c66dbe00 154with the name (for example) @file{libnss_@var{name}.so.2}. The number
706074a5
UD
155at the end is the currently used version of the interface which will not
156change frequently. Normally the user should not have to be cognizant of
157these files since they should be placed in a directory where they are
158found automatically. Only the names of all available services are
159important.
160
161@node Actions in the NSS configuration, Notes on NSS Configuration File, Services in the NSS configuration, NSS Configuration File
162@subsection Actions in the NSS configuration
163
164The second item in the specification gives the user much finer control
165on the lookup process. Action items are placed between two service
166names and are written within brackets. The general form is
167
2de99474 168@display
57ba7bb4 169@code{[} ( @code{!}? @var{status} @code{=} @var{action} )+ @code{]}
2de99474 170@end display
706074a5
UD
171
172@noindent
173where
174
175@smallexample
176@var{status} @result{} success | notfound | unavail | tryagain
177@var{action} @result{} return | continue
178@end smallexample
179
180The case of the keywords is insignificant. The @var{status}
181values are the results of a call to a lookup function of a specific
182service. They mean
183
184@ftable @samp
185@item success
6d52618b 186No error occurred and the wanted entry is returned. The default action
706074a5
UD
187for this is @code{return}.
188
189@item notfound
190The lookup process works ok but the needed value was not found. The
191default action is @code{continue}.
192
193@item unavail
194@cindex DNS server unavailable
195The service is permanently unavailable. This can either mean the needed
196file is not available, or, for DNS, the server is not available or does
197not allow queries. The default action is @code{continue}.
198
199@item tryagain
200The service is temporarily unavailable. This could mean a file is
201locked or a server currently cannot accept more connections. The
202default action is @code{continue}.
203@end ftable
204
205@noindent
206If we have a line like
207
208@smallexample
209ethers: nisplus [NOTFOUND=return] db files
210@end smallexample
211
212@noindent
213this is equivalent to
214
215@smallexample
216ethers: nisplus [SUCCESS=return NOTFOUND=return UNAVAIL=continue
217 TRYAGAIN=continue]
218 db [SUCCESS=return NOTFOUND=continue UNAVAIL=continue
219 TRYAGAIN=continue]
220 files
221@end smallexample
222
223@noindent
224(except that it would have to be written on one line). The default
225value for the actions are normally what you want, and only need to be
226changed in exceptional cases.
227
228If the optional @code{!} is placed before the @var{status} this means
4f8dbcb1 229the following action is used for all statuses but @var{status} itself.
706074a5
UD
230I.e., @code{!} is negation as in the C language (and others).
231
232Before we explain the exception which makes this action item necessary
233one more remark: obviously it makes no sense to add another action
234item after the @code{files} service. Since there is no other service
235following the action @emph{always} is @code{return}.
236
237@cindex nisplus, and completeness
238Now, why is this @code{[NOTFOUND=return]} action useful? To understand
239this we should know that the @code{nisplus} service is often
240complete; i.e., if an entry is not available in the NIS+ tables it is
241not available anywhere else. This is what is expressed by this action
242item: it is useless to examine further services since they will not give
243us a result.
244
245@cindex nisplus, and booting
246@cindex bootstrapping, and services
247The situation would be different if the NIS+ service is not available
248because the machine is booting. In this case the return value of the
249lookup function is not @code{notfound} but instead @code{unavail}. And
250as you can see in the complete form above: in this situation the
251@code{db} and @code{files} services are used. Neat, isn't it? The
252system administrator need not pay special care for the time the system
253is not completely ready to work (while booting or shutdown or
254network problems).
255
256
257@node Notes on NSS Configuration File, , Actions in the NSS configuration, NSS Configuration File
258@subsection Notes on the NSS Configuration File
259
260Finally a few more hints. The NSS implementation is not completely
261helpless if @file{/etc/nsswitch.conf} does not exist. For
262all supported databases there is a default value so it should normally
263be possible to get the system running even if the file is corrupted or
264missing.
265
ba1ffaa1 266@cindex default value, and NSS
b3a86ae1 267For the @code{hosts} and @code{networks} databases the default value is
ba1ffaa1
UD
268@code{dns [!UNAVAIL=return] files}. I.e., the system is prepared for
269the DNS service not to be available but if it is available the answer it
270returns is ultimative.
271
10dc2a90
UD
272The @code{passwd}, @code{group}, and @code{shadow} databases are
273traditionally handled in a special way. The appropriate files in the
274@file{/etc} directory are read but if an entry with a name starting
275with a @code{+} character is found NIS is used. This kind of lookup
276remains possible by using the special lookup service @code{compat}
277and the default value for the three databases above is
278@code{compat [NOTFOUND=return] files}.
279
ba1ffaa1 280For all other databases the default value is
10dc2a90
UD
281@code{nis [NOTFOUND=return] files}. This solution give the best
282chance to be correct since NIS and file based lookup is used.
ba1ffaa1
UD
283
284@cindex optimizing NSS
706074a5 285A second point is that the user should try to optimize the lookup
10dc2a90
UD
286process. The different service have different response times.
287A simple file look up on a local file could be fast, but if the file
288is long and the needed entry is near the end of the file this may take
289quite some time. In this case it might be better to use the @code{db}
290service which allows fast local access to large data sets.
706074a5
UD
291
292Often the situation is that some global information like NIS must be
293used. So it is unavoidable to use service entries like @code{nis} etc.
294But one should avoid slow services like this if possible.
295
296
297@node NSS Module Internals, Extending NSS, NSS Configuration File, Name Service Switch
298@section NSS Module Internals
299
300Now it is time to described how the modules look like. The functions
301contained in a module are identified by their names. I.e., there is no
302jump table or the like. How this is done is of no interest here; those
303interested in this topic should read about Dynamic Linking.
304@comment @ref{Dynamic Linking}.
305
306
307@menu
308* NSS Module Names:: Construction of the interface function of
309 the NSS modules.
310* NSS Modules Interface:: Programming interface in the NSS module
311 functions.
312@end menu
313
314@node NSS Module Names, NSS Modules Interface, NSS Module Internals, NSS Module Internals
315@subsection The Naming Scheme of the NSS Modules
316
317@noindent
318The name of each function consist of various parts:
319
320@quotation
321 _nss_@var{service}_@var{function}
322@end quotation
323
324@var{service} of course corresponds to the name of the module this
325function is found in.@footnote{Now you might ask why to duplicate this
326information. The answer is that we want to keep the possibility to link
327directly with these shared objects.} The @var{function} part is derived
328from the interface function in the C library itself. If the user calls
329the function @code{gethostbyname} and the service used is @code{files}
330the function
331
332@smallexample
333 _nss_files_gethostbyname_r
334@end smallexample
335
336@noindent
337in the module
338
339@smallexample
c66dbe00 340 libnss_files.so.2
706074a5
UD
341@end smallexample
342
343@noindent
344@cindex reentrant NSS functions
345is used. You see, what is explained above in not the whole truth. In
346fact the NSS modules only contain reentrant versions of the lookup
347functions. I.e., if the user would call the @code{gethostbyname_r}
348function this also would end in the above function. For all user
349interface functions the C library maps this call to a call to the
350reentrant function. For reentrant functions this is trivial since the
26dee9c4
UD
351interface is (nearly) the same. For the non-reentrant version The
352library keeps internal buffers which are used to replace the user
353supplied buffer.
706074a5
UD
354
355I.e., the reentrant functions @emph{can} have counterparts. No service
356module is forced to have functions for all databases and all kinds to
357access them. If a function is not available it is simply treated as if
358the function would return @code{unavail}
359(@pxref{Actions in the NSS configuration}).
360
c66dbe00
UD
361The file name @file{libnss_files.so.2} would be on a @w{Solaris 2}
362system @file{nss_files.so.2}. This is the difference mentioned above.
2de99474
UD
363Sun's NSS modules are usable as modules which get indirectly loaded
364only.
365
366The NSS modules in the GNU C Library are prepared to be used as normal
367libraries itself.
368@comment Fix me if necessary.
369This is @emph{not} true in the moment, though. But the different
370organization of the name space in the modules does not make it
371impossible like it is for Solaris. Now you can see why the modules are
372still libraries.@footnote{There is a second explanation: we were too
373lazy to change the Makefiles to allow the generation of shared objects
374not starting with @file{lib} but do not tell this anybody.}
375
706074a5
UD
376
377@node NSS Modules Interface, , NSS Module Names, NSS Module Internals
378@subsection The Interface of the Function in NSS Modules
379
380Now we know about the functions contained in the modules. It is now
381time to describe the types. When we mentioned the reentrant versions of
382the functions above, this means there are some additional arguments
383(compared with the standard, non-reentrant version). The prototypes for
384the non-reentrant and reentrant versions of our function above are:
385
386@smallexample
387struct hostent *gethostbyname (const char *name)
388
a18f587d
UD
389int gethostbyname_r (const char *name, struct hostent *result_buf,
390 char *buf, size_t buflen, struct hostent **result,
391 int *h_errnop)
706074a5
UD
392@end smallexample
393
394@noindent
ba1ffaa1 395The actual prototype of the function in the NSS modules in this case is
706074a5
UD
396
397@smallexample
ba1ffaa1
UD
398enum nss_status _nss_files_gethostbyname_r (const char *name,
399 struct hostent *result_buf,
a18f587d 400 char *buf, size_t buflen,
c66dbe00 401 int *errnop, int *h_errnop)
706074a5
UD
402@end smallexample
403
ba1ffaa1 404I.e., the interface function is in fact the reentrant function with the
26dee9c4
UD
405change of the return value and the omission of the @var{result}
406parameter. While the user-level function returns a pointer to the
407result the reentrant function return an @code{enum nss_status} value:
706074a5 408
2c6fe0bd
UD
409@vindex NSS_STATUS_TRYAGAIN
410@vindex NSS_STATUS_UNAVAIL
411@vindex NSS_STATUS_NOTFOUND
412@vindex NSS_STATUS_SUCCESS
706074a5
UD
413@ftable @code
414@item NSS_STATUS_TRYAGAIN
415numeric value @code{-2}
416
417@item NSS_STATUS_UNAVAIL
418numeric value @code{-1}
419
420@item NSS_STATUS_NOTFOUND
421numeric value @code{0}
422
423@item NSS_STATUS_SUCCESS
424numeric value @code{1}
425@end ftable
426
427@noindent
428Now you see where the action items of the @file{/etc/nsswitch.conf} file
429are used.
430
ba1ffaa1
UD
431If you study the source code you will find there is a fifth value:
432@code{NSS_STATUS_RETURN}. This is an internal use only value, used by a
433few functions in places where none of the above value can be used. If
434necessary the source code should be examined to learn about the details.
435
7be8096f
UD
436In case the interface function has to return an error it is important
437that the correct error code is stored in @code{*@var{errnop}}. Some
438return status value have only one associated error code, others have
439more.
440
441@multitable @columnfractions .3 .2 .50
442@item
443@code{NSS_STATUS_TRYAGAIN} @tab
444 @code{EAGAIN} @tab One functions used ran temporarily out of
445resources or a service is currently not available.
446@item
447@tab
448 @code{ERANGE} @tab The provided buffer is not large enough.
449The function should be called again with a larger buffer.
450@item
451@code{NSS_STATUS_UNAVAIL} @tab
452 @code{ENOENT} @tab A necessary input file cannot be found.
453@item
454@code{NSS_STATUS_NOTFOUND} @tab
455 @code{ENOENT} @tab The requested entry is not available.
456@end multitable
457
458These are proposed values. There can be other error codes and the
459described error codes can have different meaning. @strong{With one
460exception:} when returning @code{NSS_STATUS_TRYAGAIN} the error code
461@code{ERANGE} @emph{must} mean that the user provided buffer is too
462small. Everything is non-critical.
463
ba1ffaa1 464The above function has something special which is missing for almost all
706074a5
UD
465the other module functions. There is an argument @var{h_errnop}. This
466points to a variable which will be filled with the error code in case
467the execution of the function fails for some reason. The reentrant
468function cannot use the global variable @var{h_errno};
7be8096f
UD
469@code{gethostbyname} calls @code{gethostbyname_r} with the last argument
470set to @code{&h_errno}.
706074a5
UD
471
472The @code{get@var{XXX}by@var{YYY}} functions are the most important
473functions in the NSS modules. But there are others which implement
474the other ways to access system databases (say for the
475password database, there are @code{setpwent}, @code{getpwent}, and
476@code{endpwent}). These will be described in more detail later.
477Here we give a general way to determine the
478signature of the module function:
479
480@itemize @bullet
481@item
482the return value is @code{int};
483@item
484the name is as explain in @pxref{NSS Module Names};
485@item
486the first arguments are identical to the arguments of the non-reentrant
487function;
488@item
489the next three arguments are:
490
491@table @code
26dee9c4 492@item STRUCT_TYPE *result_buf
706074a5
UD
493pointer to buffer where the result is stored. @code{STRUCT_TYPE} is
494normally a struct which corresponds to the database.
495@item char *buffer
496pointer to a buffer where the function can store additional adata for
497the result etc.
26dee9c4 498@item size_t buflen
706074a5
UD
499length of the buffer pointed to by @var{buffer}.
500@end table
501
502@item
503possibly a last argument @var{h_errnop}, for the host name and network
504name lookup functions.
505@end itemize
506
507@noindent
508This table is correct for all functions but the @code{set@dots{}ent}
509and @code{end@dots{}ent} functions.
510
511
512@node Extending NSS, , NSS Module Internals, Name Service Switch
513@section Extending NSS
514
515One of the advantages of NSS mentioned above is that it can be extended
516quite easily. There are two ways in which the extension can happen:
517adding another database or adding another service. The former is
518normally done only by the C library developers. It is
519here only important to remember that adding another database is
520independent from adding another service because a service need not
521support all databases or lookup functions.
522
523A designer/implementor of a new service is therefore free to choose the
524databases s/he is interested in and leave the rest for later (or
525completely aside).
526
527@menu
528* Adding another Service to NSS:: What is to do to add a new service.
529* NSS Module Function Internals:: Guidelines for writing new NSS
530 service functions.
531@end menu
532
533@node Adding another Service to NSS, NSS Module Function Internals, Extending NSS, Extending NSS
534@subsection Adding another Service to NSS
535
536The sources for a new service need not (and should not) be part of the
537GNU C Library itself. The developer retains complete control over the
538sources and its development. The links between the C library and the
539new service module consists solely of the interface functions.
540
541Each module is designed following a specific interface specification.
c66dbe00
UD
542For now the version is 2 (the interface in version 1 was not adequate)
543and this manifests in the version number of the shared library object of
544the NSS modules: they have the extension @code{.2}. If the interface
545changes again in an incompatible way, this number will be increased.
706074a5
UD
546Modules using the old interface will still be usable.
547
548Developers of a new service will have to make sure that their module is
549created using the correct interface number. This means the file itself
550must have the correct name and on ElF systems the @dfn{soname} (Shared
551Object Name) must also have this number. Building a module from a bunch
552of object files on an ELF system using GNU CC could be done like this:
553
554@smallexample
c66dbe00 555gcc -shared -o libnss_NAME.so.2 -Wl,-soname,libnss_NAME.so.2 OBJECTS
706074a5
UD
556@end smallexample
557
558@noindent
559@ref{Link Options, Options for Linking, , gcc, GNU CC}, to learn
560more about this command line.
561
562To use the new module the library must be able to find it. This can be
563achieved by using options for the dynamic linker so that it will search
564directory where the binary is placed. For an ELF system this could be
565done by adding the wanted directory to the value of
566@code{LD_LIBRARY_PATH}.
567
568But this is not always possible since some program (those which run
569under IDs which do not belong to the user) ignore this variable.
570Therefore the stable version of the module should be placed into a
571directory which is searched by the dynamic linker. Normally this should
572be the directory @file{$prefix/lib}, where @file{$prefix} corresponds to
573the value given to configure using the @code{--prefix} option. But be
574careful: this should only be done if it is clear the module does not
575cause any harm. System administrators should be careful.
576
577
578@node NSS Module Function Internals, , Adding another Service to NSS, Extending NSS
579@subsection Internals of the NSS Module Functions
580
581Until now we only provided the syntactic interface for the functions in
582the NSS module. In fact there is not more much we can tell since the
583implementation obviously is different for each function. But a few
584general rules must be followed by all functions.
585
586In fact there are four kinds of different functions which may appear in
587the interface. All derive from the traditional ones for system databases.
588@var{db} in the following table is normally an abbreviation for the
589database (e.g., it is @code{pw} for the password database).
590
591@table @code
a18f587d 592@item enum nss_status _nss_@var{database}_set@var{db}ent (void)
706074a5
UD
593This function prepares the service for following operations. For a
594simple file based lookup this means files could be opened, for other
595services this function simply is a noop.
596
597One special case for this function is that it takes an additional
598argument for some @var{database}s (i.e., the interface is
599@code{int set@var{db}ent (int)}). @ref{Host Names}, which describes the
600@code{sethostent} function.
601
602The return value should be @var{NSS_STATUS_SUCCESS} or according to the
603table above in case of an error (@pxref{NSS Modules Interface}).
604
a18f587d 605@item enum nss_status _nss_@var{database}_end@var{db}ent (void)
706074a5
UD
606This function simply closes all files which are still open or removes
607buffer caches. If there are no files or buffers to remove this is again
608a simple noop.
609
610There normally is no return value different to @var{NSS_STATUS_SUCCESS}.
611
c66dbe00 612@item enum nss_status _nss_@var{database}_get@var{db}ent_r (@var{STRUCTURE} *result, char *buffer, size_t buflen, int *errnop)
706074a5
UD
613Since this function will be called several times in a row to retrieve
614one entry after the other it must keep some kind of state. But this
615also means the functions are not really reentrant. They are reentrant
616only in that simultaneous calls to this function will not try to
617write the retrieved data in the same place (as it would be the case for
618the non-reentrant functions); instead, it writes to the structure
619pointed to by the @var{result} parameter. But the calls share a common
620state and in the case of a file access this means they return neighboring
621entries in the file.
622
623The buffer of length @var{buflen} pointed to by @var{buffer} can be used
624for storing some additional data for the result. It is @emph{not}
625guaranteed that the same buffer will be passed for the next call of this
626function. Therefore one must not misuse this buffer to save some state
627information from one call to another.
628
c66dbe00
UD
629Before the function returns the implementation should store the value of
630the local @var{errno} variable in the variable pointed to be
631@var{errnop}. This is important to guarantee the module working in
632statically linked programs.
633
706074a5
UD
634As explained above this function could also have an additional last
635argument. This depends on the database used; it happens only for
b3a86ae1 636@code{host} and @code{networks}.
706074a5
UD
637
638The function shall return @code{NSS_STATUS_SUCCESS} as long as their are
639more entries. When the last entry was read it should return
640@code{NSS_STATUS_NOTFOUND}. When the buffer given as an argument is too
641small for the data to be returned @code{NSS_STATUS_TRYAGAIN} should be
642returned. When the service was not formerly initialized by a call to
643@code{_nss_@var{DATABASE}_set@var{db}ent} all return value allowed for
644this function can also be returned here.
645
c66dbe00 646@item enum nss_status _nss_@var{DATABASE}_get@var{db}by@var{XX}_r (@var{PARAMS}, @var{STRUCTURE} *result, char *buffer, size_t buflen, int *errnop)
706074a5
UD
647This function shall return the entry from the database which is
648addressed by the @var{PARAMS}. The type and number of these arguments
649vary. It must be individually determined by looking to the user-level
650interface functions. All arguments given to the non-reentrant version
651are here described by @var{PARAMS}.
652
653The result must be stored in the structure pointed to by @var{result}.
654If there is additional data to return (say strings, where the
655@var{result} structure only contains pointers) the function must use the
656@var{buffer} or length @var{buflen}. There must not be any references
657to non-constant global data.
658
659The implementation of this function should honour the @var{stayopen}
660flag set by the @code{set@var{DB}ent} function whenever this makes sense.
661
c66dbe00
UD
662Before the function returns the implementation should store the value of
663the local @var{errno} variable in the variable pointed to be
664@var{errnop}. This is important to guarantee the module working in
665statically linked programs.
666
706074a5 667Again, this function takes an additional last argument for the
b3a86ae1 668@code{host} and @code{networks} database.
706074a5
UD
669
670The return value should as always follow the rules given above
671(@pxref{NSS Modules Interface}).
672
673@end table