Skip to content

Instantly share code, notes, and snippets.

Created July 22, 2012 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/96c6db8851221b2c26c0 to your computer and use it in GitHub Desktop.
Save anonymous/96c6db8851221b2c26c0 to your computer and use it in GitHub Desktop.
static int trinst_xid_swap(void)
{
uid_t ruid, euid;
gid_t rgid, egid;
// Interchange the real and effective user/group IDs
ruid = getuid();
euid = geteuid();
if (setreuid(euid, ruid) != 0)
return -errno;
rgid = getgid();
egid = getegid();
if (setregid(egid, rgid) != 0)
return -errno;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment