Referring the "inconsistent" error message:
If getpwuid()
returns NULL
, this not necessarilly needs to inidicate an error.
From man getpwuid
(italic emphasis by me):
The getpwuid() function returns a pointer to a structure containing the broken-out fields of the record in the password database that matches the user ID uid.
[...]
The getpwnam() and getpwuid() functions return a pointer to a passwd structure, or NULL if the matching entry is not found or an error occurs.
From the fact that errno
seems to be 0
anf those two statments above I'd conclude that the result of geteuid()
simply could not be found by getpwuid()
.