getgrnam(3) Library Functions Manual getgrnam(3) getgrnam, getgrnam_r, getgrgid, getgrgid_r - Standard C library (libc, -lc) #include #include struct group *getgrnam(const char *name); struct group *getgrgid(gid_t gid); int getgrnam_r(const char *restrict name, struct group *restrict grp, char buf[restrict .size], size_t size, struct group **restrict result); int getgrgid_r(gid_t gid, struct group *restrict grp, char buf[restrict .size], size_t size, struct group **restrict result); glibc (. feature_test_macros(7)): getgrnam_r(), getgrgid_r(): _POSIX_C_SOURCE || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE getgrnam() , (, /etc/group, NIS LDAP), name. getgrgid() , , gid. group : struct group { char *gr_name; /* */ char *gr_passwd; /* */ gid_t gr_gid; /* ID */ char **gr_mem; /* , , NULL */ }; group(5). The getgrnam_r() and getgrgid_r() functions obtain the same information as getgrnam() and getgrgid(), but store the retrieved group structure in the space pointed to by grp. The string fields pointed to by the members of the group structure are stored in the buffer buf of size size. A pointer to the result (in case of success) or NULL (in case no entry was found or an error occurred) is stored in *result. sysconf(_SC_GETGR_R_SIZE_MAX) -1 errno buf ( , ERANGE; ). The getgrnam() and getgrgid() functions return a pointer to a group structure, or NULL if the matching entry is not found or an error occurs. If an error occurs, errno is set to indicate the error. If one wants to check errno after the call, it should be set to zero before the call. getgrent(3), getgrnam() getgrgid() ( free(3)). getgrnam_r() getgrgid_r() , *result pwd. , 0 NULL *result. *result NULL. 0 ENOENT ESRCH EBADF EPERM ... name gid . EINTR ; . signal(7). EIO -. EMFILE . ENFILE . ENOMEM group. ERANGE . /etc/group attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |getgrnam() | | MT-Unsafe race:grnam | | | | locale | +----------------------------+----------------------------------------------------------+--------------------------+ |getgrgid() | | MT-Unsafe race:grgid | | | | locale | +----------------------------+----------------------------------------------------------+--------------------------+ |getgrnam_r(), getgrgid_r() | | MT-Safe locale | +----------------------------+----------------------------------------------------------+--------------------------+ << >>, , POSIX.1. << >> , errno . . POSIX , errno , . UNIX- , : 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM , , . POSIX.1-2008. POSIX.1-2001, SVr4, 4.3BSD. endgrent(3), fgetgrent(3), getgrent(3), getpwnam(3), setgrent(3), group(5) () Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux man-pages 6.12 24 2024 . getgrnam(3)