POSIX code for impersonation