ENDGRENT(3POSIX)
β¨ ENDGRENT(3POSIX) β¨
okay bestie, this is endgrent(3POSIX) from the POSIX Programmer's Manual β the group database trilogy, the girlies who let you walk through /etc/group like it's a group chat you're scrolling from the top π
πΈ PROLOG πΈ
real talk first: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so pls go check the corresponding Linux manual page for the tea on Linux behavior), or honestly the interface may not be implemented on Linux at all π
π NAME π
endgrent, getgrent, setgrent β group database entry functions. the trio. the moment. β¨
π SYNOPSIS π
#include <grp.h>
void endgrent(void);
struct group *getgrent(void);
void setgrent(void);
π¦ DESCRIPTION π¦
okay so here's the vibe:
getgrent() shall return a pointer to a structure containing the broken-out fields of an entry in the group database. If the group database is not already open, getgrent() shall open it and return a pointer to a group structure containing the first entry in the database. After that, it shall return a pointer to a group structure containing the next group structure in the group database, so successive calls may be used to search the entire database. it's giving "walk the whole list, one entry at a time" π
An implementation that provides extended security controls may impose further implementation-defined restrictions on accessing the group database. In particular β and this is the part that lowkey matters β the system may deny the existence of some or all of the group database entries associated with groups other than those groups associated with the caller, and may omit users other than the caller from the list of members of groups in database entries that are returned. so like, your view of the group db might be curated for you. main character privilege, honestly. π
setgrent() shall rewind the group database so that the next getgrent() call returns the first entry, allowing repeated searches. rewind era. π
endgrent() shall close the group database. bye babe π«Ά
The setgrent() and endgrent() functions shall not change the setting of errno if successful. iconique behavior, no side effects, we love her.
On error, the setgrent() and endgrent() functions shall set errno to indicate the error.
Since no value is returned by the setgrent() and endgrent() functions, an application wishing to check for error situations should:
- set
errnoto0 - then call the function
- then check
errno
π heads up: these functions need not be thread-safe. fr fr. plan accordingly.
π RETURN VALUE π
On successful completion, getgrent() shall return a pointer to a group structure.
On end-of-file, getgrent() shall return a null pointer and shall not change the setting of errno.
On error, getgrent() shall return a null pointer and errno shall be set to indicate the error.
now the important boundary, bestie, listen up:
The application shall not modify the structure to which the return value points, nor any storage areas pointed to by pointers within the structure. π ββοΈ
The returned pointer, and pointers within the structure, might be invalidated or the structure or the storage areas might be overwritten by a subsequent call to getgrgid(), getgrnam(), or getgrent(). The returned pointer, and pointers within the structure, might also be invalidated if the calling thread is terminated. so basically, don't hold onto it like it's a forever thing. it's a situationship. π
π ERRORS π
These functions may fail if:
EINTRβ A signal was caught during the operation.EIOβ An I/O error has occurred.
In addition, the getgrent() and setgrent() functions may fail if:
EMFILEβ All file descriptors available to the process are currently open.ENFILEβ The maximum allowable number of files is currently open in the system.
The following sections are informative.
π EXAMPLES π
None.
(not one. zero. the void. β)
π§ APPLICATION USAGE π§
These functions are provided due to their historical usage. Applications should avoid dependencies on fields in the group database, whether the database is a single file, or where in the file system name space the database resides.
Applications should use getgrnam() and getgrgid() whenever possible because it avoids these dependencies. so like, the OGs are cute for nostalgia but the glow-up versions are getgrnam() and getgrgid(). periodt. π
π RATIONALE π
None.
π FUTURE DIRECTIONS π
None.
π₯ SEE ALSO π₯
endpwent()getgrgid()getgrnam()getlogin()
The Base Definitions volume of POSIX.1β2017, <grp.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay that's the whole page, we ate and left no crumbs π IEEE/The Open Group dropped this in 2017, page ENDGRENT(3POSIX), and honestly? iconic of them. mwah πβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms