Only check errno if getpwuid() fails

Checking errno otherwise is unspecified.