Fix UnixUser.set_selinux_context to work with files and dirs

Refactor UnixUser.set_selinux_context to work with both files
and directories. Previously only worked with directories, causing
the write_ssh_keys function to fail as it passed the authorized_keys
file which was treated as a directory.