title: Set another userid to current process
body: <p>I want to set current process's effective uid to other user's uid (or a arbitrary value). </p>
  
  <pre><code>struct passwd* pwHost = getpwnam(hostName);//hostName is another user's name
  struct passwd* pwGuest = getpwnam(guestName);//guestName is the current log-in user's name
  if(pwHost==NULL||pwGuest==NULL)
  {
      printf("User cannot be found\n");
      exit(0);
  }
  
  //setresuid(pwGuest-&gt;pw_uid, pwHost-&gt;pw_uid, pwGuest-&gt;pw_uid);//change the effective uid of current process to the host uid
  setresuid(1000, 1000, 1000);//change current process's uid to a arbitrary value
  printf("Host uid: %u\n", pwHost-&gt;pw_uid);
  printf("Guest uid: %u\n", pwGuest-&gt;pw_uid);
  
  static uid_t euid, ruid, suid;
  getresuid(&amp;euid, &amp;ruid, &amp;suid); 
  printf("euid: %u\n", euid);
  printf("ruid: %u\n", ruid);
  printf("suid: %u\n", suid);
  printf("Set permission complete\n");
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Host uid: 35917
  Guest uid: 35917
  euid: 35917
  ruid: 35917
  suid: 35917
  </code></pre>
  
  <p>However, it seems like none of them has been changed yet. I looked-up the manual, which explains that user needs a privilege or something I don't quite understand. Could anyone give me some hints of how to achieve my goal? Thanks a lot. </p>