New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
errno should be reset to 0 before each call to getpwent() in genhomedircon #121
Comments
bigon
added a commit
to bigon/selinux
that referenced
this issue
Jan 2, 2019
The manpage explicitly states that: The getpwent() function returns a pointer to a passwd structure, or NULL if there are no more entries or an error occurred. If an error occurs, errno is set appropriately. If one wants to check errno after the call, it should be set to zero before the call. Without this, genhomedircon can wrongly return the following: libsemanage.get_home_dirs: Error while fetching users. Returning list so far. SELinuxProject#121 Signed-off-by: Laurent Bigonville <bigon@bigon.be>
fishilico
pushed a commit
to fishilico/selinux
that referenced
this issue
Jan 5, 2019
The manpage explicitly states that: The getpwent() function returns a pointer to a passwd structure, or NULL if there are no more entries or an error occurred. If an error occurs, errno is set appropriately. If one wants to check errno after the call, it should be set to zero before the call. Without this, genhomedircon can wrongly return the following: libsemanage.get_home_dirs: Error while fetching users. Returning list so far. SELinuxProject#121 Signed-off-by: Laurent Bigonville <bigon@bigon.be>
The catch is this issue is that For future reference, here is a simple test program to illustrate this behavior: #include <sys/types.h>
#include <pwd.h>
#include <errno.h>
#include <stdio.h>
int main(void)
{
struct passwd *pw;
setpwent();
errno = 0;
while ((pw = getpwent()) != NULL) {
printf("%d: %s (errno %d)\n", pw->pw_uid, pw->pw_name, errno);
errno = 0;
}
printf("getpwent errno = %d (%m)\n", errno);
endpwent();
return 0;
} Its output (in a Vagrant virtual machine with glibc 2.28 and systemd 239.370 is:
I merged your commit. Thanks! |
bachradsusi
pushed a commit
to bachradsusi/selinux
that referenced
this issue
Jan 7, 2019
The manpage explicitly states that: The getpwent() function returns a pointer to a passwd structure, or NULL if there are no more entries or an error occurred. If an error occurs, errno is set appropriately. If one wants to check errno after the call, it should be set to zero before the call. Without this, genhomedircon can wrongly return the following: libsemanage.get_home_dirs: Error while fetching users. Returning list so far. SELinuxProject/selinux#121 Signed-off-by: Laurent Bigonville <bigon@bigon.be>
charleseb
pushed a commit
to MotorolaMobilityLLC/external-selinux
that referenced
this issue
Jan 21, 2020
The manpage explicitly states that: The getpwent() function returns a pointer to a passwd structure, or NULL if there are no more entries or an error occurred. If an error occurs, errno is set appropriately. If one wants to check errno after the call, it should be set to zero before the call. Without this, genhomedircon can wrongly return the following: libsemanage.get_home_dirs: Error while fetching users. Returning list so far. SELinuxProject/selinux#121 Signed-off-by: Laurent Bigonville <bigon@bigon.be>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
In
genhomedircon
, it seems thaterrno
should be reset to 0 before each call togetpwent()
The manpage of
getpwent()
states:Without this,
genhomedircon
can wrongly return the following error when using thefiles
module:The text was updated successfully, but these errors were encountered: