Hi all,
Recently Linaro issued the toolchain for arm64/ilp32 [1], and
running LTP compiled with it, I found multiple regressions. I
tracked them down to function family getpw*(). The problem is
that they return NULL, and don't set any errno.
#include <sys/types.h>
#include <pwd.h>
#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
int main(void)
{
struct passwd *pwent;
uid_t uid = getuid();
printf("uid == %d, errno = %d\n", uid,
errno);
pwent = getpwuid(uid);
printf("pwent == %p, errno == %d\n", pwent, errno);
return 0;
}
Steve Ellcey noticed that it's related to the "passwd: compat"
record in /etc/nsswitch.conf. On my testing system (Ubuntu 14.04) I replaced the
file with one coming in glibc sources (passwd is "db_files" there), and it fixed
the problem.
By this email I'd like to report the issue to community and ask some
questions:
- I think it shuld be a bug if function returns NULL instead the pointer
to the structure, and doesn't set errno. The POSIX [2] is not
specific here: "If getpwuid() returns a null pointer and errno is
set to non-zero, an error occurred". But if getpwuid() returns null,
it is an error from user point of view (LTP treats is like this for
example). But Glibc doesn't set errno, and POSIX doesn't restrict it
explicitly.