Support unexpected events when trying to get the user's home directory

This patch makes sure that the program does not segfault
if it failes to read the passwd file or if the user does not have
an entry in the passwd file. It also not try to construct a pathname
with the user's home directory if missing from the passwd file,
i.e. null or empty.