Fixed possible dereference of null pointer

getpwuid() can return null. For example, Shun Sakuruba reported that
on Cray XE6 compute nodes have passwd.h, but users will not have
passwd entries.

Fixes #1301

Change-Id: I66e8064438fc02591629b0d381bc00afd06795c0