The lookup functions for netgroups are a bit different to all other system database handling functions. Since a single netgroup can contain many entries a two-step process is needed. First a single netgroup is selected and then one can iterate over all entries in this netgroup. These functions are declared in `netdb.h'.
getnetgrentiterate over all entries in the netgroup with name netgroup.
When the call is successful (i.e., when a netgroup with this name exist)
the return value is
1. When the return value is
netgroup of this name is known or some other error occurred.
It is important to remember that there is only one single state for
iterating the netgroups. Even if the programmer uses the
getnetgrent_r function the result is not really reentrant since
always only one single netgroup at a time can be processed. If the
program needs to process more than one netgroup simultaneously she
must protect this by using external locking. This problem was
introduced in the original netgroups implementation in SunOS and since
we must stay compatible it is not possible to change this.
Some other functions also use the netgroups state. Currently these are
innetgr function and parts of the implementation of the
compat service part of the NSS implementation.
NULL. The returned string pointers are only valid unless no of the netgroup related functions are called.
The return value is
1 if the next entry was successfully read. A
0 means no further entries exist or internal errors occurred.
getnetgrentwith only one exception: the strings the three string pointers hostp, userp, and domainp point to, are placed in the buffer of buflen bytes starting at buffer. This means the returned values are valid even after other netgroup related functions are called.
The return value is
1 if the next entry was successfully read and
the buffer contains enough room to place the strings in it.
returned in case no more entries are found, the buffer is too small, or
internal errors occurred.
This function is a GNU extension. The original implementation in the SunOS libc does not provide this function.
getnetgrentare invalid afterwards.
Go to the first, previous, next, last section, table of contents.