man-pages/man3/setnetgrent.3.html
2021-03-31 01:06:50 +01:00

260 lines
5.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SETNETGRENT</TITLE>
</HEAD><BODY>
<H1>SETNETGRENT</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
setnetgrent, endnetgrent, getnetgrent, getnetgrent_r, innetgr -
handle network group entries
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/netdb.h">netdb.h</A>&gt;</B>
<B>int setnetgrent(const char *</B><I>netgroup</I><B>);</B>
<B>void endnetgrent(void);</B>
<B>int getnetgrent(char **</B><I>host</I><B>, char **</B><I>user</I><B>, char **</B><I>domain</I><B>);</B>
<B>int getnetgrent_r(char **</B><I>host</I><B>, char **</B><I>user</I><B>,</B>
<B> char **</B><I>domain</I><B>, char *</B><I>buf</I><B>, size_t </B><I>buflen</I><B>);</B>
<B>int innetgr(const char *</B><I>netgroup</I><B>, const char *</B><I>host</I><B>,</B>
<B> const char *</B><I>user</I><B>, const char *</B><I>domain</I><B>);</B>
</PRE>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>setnetgrent</B>(),
<B>endnetgrent</B>(),
<B>getnetgrent</B>(),
<B>getnetgrent_r</B>(),
<B>innetgr</B>():
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Since&nbsp;glibc&nbsp;2.19:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_DEFAULT_SOURCE
<BR>&nbsp;&nbsp;&nbsp;&nbsp;Glibc&nbsp;2.19&nbsp;and&nbsp;earlier:
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_BSD_SOURCE&nbsp;||&nbsp;_SVID_SOURCE
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<I>netgroup</I>
is a SunOS invention.
A netgroup database is a list of string triples
(<I>hostname</I>, <I>username</I>, <I>domainname</I>)
or other netgroup names.
Any of the elements in a triple can be empty,
which means that anything matches.
The functions described here allow access to the netgroup databases.
The file
<I>/etc/nsswitch.conf</I>
defines what database is searched.
<P>
The
<B>setnetgrent</B>()
call defines the netgroup that will be searched by subsequent
<B>getnetgrent</B>()
calls.
The
<B>getnetgrent</B>()
function retrieves the next netgroup entry, and returns pointers in
<I>host</I>,
<I>user</I>,
<I>domain</I>.
A null pointer means that the corresponding entry matches any string.
The pointers are valid only as long as there is no call to other
netgroup-related functions.
To avoid this problem you can use the GNU function
<B>getnetgrent_r</B>()
that stores the strings in the supplied buffer.
To free all allocated buffers use
<B>endnetgrent</B>().
<P>
In most cases you want to check only if the triplet
(<I>hostname</I>, <I>username</I>, <I>domainname</I>)
is a member of a netgroup.
The function
<B>innetgr</B>()
can be used for this without calling the above three functions.
Again, a null pointer is a wildcard and matches any string.
The function is thread-safe.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
These functions return 1 on success and 0 for failure.
<A NAME="lbAF">&nbsp;</A>
<H2>FILES</H2>
<I>/etc/netgroup</I>
<BR>
<I>/etc/nsswitch.conf</I>
<A NAME="lbAG">&nbsp;</A>
<H2>ATTRIBUTES</H2>
For an explanation of the terms used in this section, see
<B><A HREF="/cgi-bin/man/man2html?7+attributes">attributes</A></B>(7).
<TABLE BORDER>
<TR VALIGN=top><TD><B>Interface</B></TD><TD><B>Attribute</B></TD><TD><B>Value</B><BR></TD></TR>
<TR VALIGN=top><TD>
<B>setnetgrent</B>(),
<BR>
<B>getnetgrent_r</B>(),
<BR>
<B>innetgr</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netgrent
<BR>
locale
<BR></TD></TR>
<TR VALIGN=top><TD>
<B>endnetgrent</B>()
</TD><TD>Thread safety</TD><TD>MT-Unsafe race:netgrent<BR></TD></TR>
<TR VALIGN=top><TD>
<B>getnetgrent</B>()
</TD><TD>Thread safety</TD><TD>
MT-Unsafe race:netgrent
<BR>
race:netgrentbuf locale
<BR></TD></TR>
</TABLE>
<P>
In the above table,
<I>netgrent</I>
in
<I>race:netgrent</I>
signifies that if any of the functions
<B>setnetgrent</B>(),
<B>getnetgrent_r</B>(),
<B>innetgr</B>(),
<B>getnetgrent</B>(),
or
<B>endnetgrent</B>()
are used in parallel in different threads of a program,
then data races could occur.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
These functions are not in POSIX.1, but
<B>setnetgrent</B>(),
<B>endnetgrent</B>(),
<B>getnetgrent</B>(),
and
<B>innetgr</B>()
are available on most UNIX systems.
<B>getnetgrent_r</B>()
is not widely available on other systems.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
In the BSD implementation,
<B>setnetgrent</B>()
returns void.
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+sethostent">sethostent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+setprotoent">setprotoent</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+setservent">setservent</A></B>(3)
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="5"><A HREF="#lbAF">FILES</A><DD>
<DT id="6"><A HREF="#lbAG">ATTRIBUTES</A><DD>
<DT id="7"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="8"><A HREF="#lbAI">NOTES</A><DD>
<DT id="9"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="10"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:56 GMT, March 31, 2021
</BODY>
</HTML>