{"id":7031,"date":"2022-12-20T19:34:42","date_gmt":"2022-12-20T22:34:42","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/getpwent-man3\/"},"modified":"2022-12-20T19:34:42","modified_gmt":"2022-12-20T22:34:42","slug":"getpwent-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/getpwent-man3\/","title":{"rendered":"GETPWENT (man3)"},"content":{"rendered":"<h1 align=\"center\">GETPWENT<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ERRORS\">ERRORS<\/a><br \/> <a href=\"#FILES\">FILES<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">getpwent, setpwent, endpwent \u2212 get password file entry<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <sys\/types.h> <br \/> #include <pwd.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>struct passwd *getpwent(void);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void setpwent(void);<\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>void endpwent(void);<\/b><\/p>\n<p style=\"margin-left:5%; margin-top: 1em\">Feature Test Macro Requirements for glibc (see <b>feature_test_macros<\/b>(7)):<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getpwent<\/b>(), <b>setpwent<\/b>(), <b>endpwent<\/b>():<\/p>\n<p style=\"margin-left:17%;\">_XOPEN_SOURCE\u00a0>=\u00a0500 <br \/> || \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Glibc since 2.19: bodies\/ usr\/ _DEFAULT_SOURCE <br \/> || \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var Glibc versions <= 2.19: bodies\/ usr\/ _BSD_SOURCE || _SVID_SOURCE<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>getpwent<\/b>() function returns a pointer to a structure containing the broken-out fields of a record from the password database (e.g., the local password file <i>\/etc\/passwd<\/i>, NIS, and LDAP). The first time <b>getpwent<\/b>() is called, it returns the first entry; thereafter, it returns successive entries.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>setpwent<\/b>() function rewinds to the beginning of the password database.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>endpwent<\/b>() function is used to close the password database after all processing has been performed.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>passwd<\/i> structure is defined in <i><pwd.h><\/i> as follows:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">struct passwd { <br \/> char *pw_name; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var username bodies\/ usr\/ <br \/> char *pw_passwd; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var user password bodies\/ usr\/ <br \/> uid_t pw_uid; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var user ID bodies\/ usr\/ <br \/> gid_t pw_gid; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var group ID bodies\/ usr\/ <br \/> char *pw_gecos; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var user information bodies\/ usr\/ <br \/> char *pw_dir; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var home directory bodies\/ usr\/ <br \/> char *pw_shell; \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var shell program bodies\/ usr\/ <br \/> };<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For more information about the fields of this structure, see <b>passwd<\/b>(5).<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>getpwent<\/b>() function returns a pointer to a <i>passwd<\/i> structure, or NULL if there are no more entries or an error occurred. If an error occurs, <i>errno<\/i> is set appropriately. If one wants to check <i>errno<\/i> after the call, it should be set to zero before the call.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The return value may point to a static area, and may be overwritten by subsequent calls to <b>getpwent<\/b>(), <b>getpwnam<\/b>(3), or <b>getpwuid<\/b>(3). (Do not pass the returned pointer to <b>free<\/b>(3).)<\/p>\n<h2>ERRORS <a name=\"ERRORS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><b>EINTR<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p style=\"margin-top: 1em\">A signal was caught; see <b>signal<\/b>(7).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EIO<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>I\/O error.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>EMFILE<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>The per-process limit on the number of open file descriptors has been reached.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENFILE<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>The system-wide limit on the total number of open files has been reached.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ENOMEM<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>Insufficient memory to allocate <i>passwd<\/i> structure.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><b>ERANGE<\/b><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"78%\">\n<p>Insufficient buffer space supplied.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>FILES <a name=\"FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>\/etc\/passwd<\/i><\/p>\n<p style=\"margin-left:22%;\">local password database file<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<p align=\"center\" style=\"margin-top: 1em\"><img decoding=\"async\" src=\"grohtml-1665661.png\" alt=\"Image grohtml-1665661.png\"><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In the above table, <i>pwent<\/i> in <i>race:pwent<\/i> signifies that if any of the functions <b>setpwent<\/b>(), <b>getpwent<\/b>(), or <b>endpwent<\/b>() are used in parallel in different threads of a program, then data races could occur.<\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. The <i>pw_gecos<\/i> field is not specified in POSIX, but is present on most implementations.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>fgetpwent<\/b>(3), <b>getpw<\/b>(3), <b>getpwent_r<\/b>(3), <b>getpwnam<\/b>(3), <b>getpwuid<\/b>(3), <b>putpwent<\/b>(3), <b>passwd<\/b>(5)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 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 https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  getpwent, setpwent, endpwent \u2212 get password file entry <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,2107,3007],"class_list":["post-7031","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-getpwent","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7031"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7031\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}