311 lines
7.5 KiB
HTML
311 lines
7.5 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of GETGRENT</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>GETGRENT</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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
getgrent, setgrent, endgrent - get group file entry
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>></B>
|
|
<B>#include <<A HREF="file:///usr/include/grp.h">grp.h</A>></B>
|
|
|
|
<B>struct group *getgrent(void);</B>
|
|
|
|
<B>void setgrent(void);</B>
|
|
|
|
<B>void endgrent(void);</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>setgrent</B>():
|
|
|
|
<DL COMPACT><DT id="1"><DD>
|
|
_XOPEN_SOURCE >= 500
|
|
|
|
<BR> || /* Glibc since 2.19: */ _DEFAULT_SOURCE
|
|
<BR> || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
|
|
</DL>
|
|
|
|
<P>
|
|
|
|
<B>getgrent</B>(),
|
|
|
|
<B>endgrent</B>():
|
|
|
|
<DL COMPACT><DT id="2"><DD>
|
|
Since glibc 2.22:
|
|
<BR> _XOPEN_SOURCE >= 500 ||
|
|
|
|
<BR> _DEFAULT_SOURCE
|
|
<BR>
|
|
|
|
Glibc 2.21 and earlier
|
|
<BR> _XOPEN_SOURCE >= 500
|
|
|
|
<BR> || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
|
|
<BR> || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
|
|
</DL>
|
|
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
The
|
|
<B>getgrent</B>()
|
|
|
|
function returns a pointer to a structure containing
|
|
the broken-out fields of a record in the group database
|
|
(e.g., the local group file
|
|
<I>/etc/group</I>,
|
|
|
|
NIS, and LDAP).
|
|
The first time
|
|
<B>getgrent</B>()
|
|
|
|
is called,
|
|
it returns the first entry; thereafter, it returns successive entries.
|
|
<P>
|
|
|
|
The
|
|
<B>setgrent</B>()
|
|
|
|
function rewinds to the beginning
|
|
of the group database, to allow repeated scans.
|
|
<P>
|
|
|
|
The
|
|
<B>endgrent</B>()
|
|
|
|
function is used to close the group database
|
|
after all processing has been performed.
|
|
<P>
|
|
|
|
The <I>group</I> structure is defined in <I><<A HREF="file:///usr/include/grp.h">grp.h</A>></I> as follows:
|
|
<P>
|
|
|
|
|
|
|
|
struct group {
|
|
<BR> char *gr_name; /* group name */
|
|
<BR> char *gr_passwd; /* group password */
|
|
<BR> gid_t gr_gid; /* group ID */
|
|
<BR> char **gr_mem; /* NULL-terminated array of pointers
|
|
<BR> to names of group members */
|
|
};
|
|
|
|
|
|
<P>
|
|
|
|
For more information about the fields of this structure, see
|
|
<B><A HREF="/cgi-bin/man/man2html?5+group">group</A></B>(5).
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
The
|
|
<B>getgrent</B>()
|
|
|
|
function returns a pointer to a
|
|
<I>group</I>
|
|
|
|
structure,
|
|
or NULL if there are no more entries or an error occurs.
|
|
<P>
|
|
|
|
Upon error,
|
|
<I>errno</I>
|
|
|
|
may be set.
|
|
If one wants to check
|
|
<I>errno</I>
|
|
|
|
after the call, it should be set to zero before the call.
|
|
<P>
|
|
|
|
The return value may point to a static area, and may be overwritten
|
|
by subsequent calls to
|
|
<B>getgrent</B>(),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrgid">getgrgid</A></B>(3),
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrnam">getgrnam</A></B>(3).
|
|
|
|
(Do not pass the returned pointer to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+free">free</A></B>(3).)
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="3"><B>EAGAIN</B>
|
|
|
|
<DD>
|
|
The service was temporarily unavailable; try again later.
|
|
For NSS backends in glibc this indicates a temporary error talking to the backend.
|
|
The error may correct itself, retrying later is suggested.
|
|
<DT id="4"><B>EINTR</B>
|
|
|
|
<DD>
|
|
A signal was caught; see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7).
|
|
|
|
<DT id="5"><B>EIO</B>
|
|
|
|
<DD>
|
|
I/O error.
|
|
<DT id="6"><B>EMFILE</B>
|
|
|
|
<DD>
|
|
The per-process limit on the number of open file descriptors has been reached.
|
|
<DT id="7"><B>ENFILE</B>
|
|
|
|
<DD>
|
|
The system-wide limit on the total number of open files has been reached.
|
|
<DT id="8">
|
|
<DD>
|
|
<B>ENOENT</B>
|
|
|
|
A necessary input file cannot be found.
|
|
For NSS backends in glibc this indicates the backend is not correctly configured.
|
|
<DT id="9"><B>ENOMEM</B>
|
|
|
|
<DD>
|
|
|
|
Insufficient memory to allocate
|
|
<I>group</I>
|
|
|
|
structure.
|
|
<DT id="10"><B>ERANGE</B>
|
|
|
|
<DD>
|
|
Insufficient buffer space supplied.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="11"><I>/etc/group</I>
|
|
|
|
<DD>
|
|
local group database file
|
|
</DL>
|
|
<A NAME="lbAH"> </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>getgrent</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>
|
|
MT-Unsafe race:grent
|
|
<BR>
|
|
|
|
race:grentbuf locale
|
|
<BR></TD></TR>
|
|
<TR VALIGN=top><TD>
|
|
<B>setgrent</B>(),
|
|
|
|
<B>endgrent</B>()
|
|
|
|
</TD><TD>Thread safety</TD><TD>MT-Unsafe race:grent locale<BR></TD></TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
In the above table,
|
|
<I>grent</I>
|
|
|
|
in
|
|
<I>race:grent</I>
|
|
|
|
signifies that if any of the functions
|
|
<B>setgrent</B>(),
|
|
|
|
<B>getgrent</B>(),
|
|
|
|
or
|
|
<B>endgrent</B>()
|
|
|
|
are used in parallel in different threads of a program,
|
|
then data races could occur.
|
|
<A NAME="lbAI"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+fgetgrent">fgetgrent</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrent_r">getgrent_r</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrgid">getgrgid</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrnam">getgrnam</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+getgrouplist">getgrouplist</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+putgrent">putgrent</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?5+group">group</A></B>(5)
|
|
|
|
<A NAME="lbAK"> </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"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="12"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="13"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="14"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="15"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="16"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="17"><A HREF="#lbAG">FILES</A><DD>
|
|
<DT id="18"><A HREF="#lbAH">ATTRIBUTES</A><DD>
|
|
<DT id="19"><A HREF="#lbAI">CONFORMING TO</A><DD>
|
|
<DT id="20"><A HREF="#lbAJ">SEE ALSO</A><DD>
|
|
<DT id="21"><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:44 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|