Improved POSIX-compliant handling of getpwnam_r() and getgrnam_r().

Signed-off-by: Andrei Belov <defanator@gmail.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>