setregid() and setreuid() implementation proposal

Pierre A. Humblet
Thu Jan 23 21:18:00 GMT 2003

Jason Tishler wrote:
> Pierre,

> I will submit the complete patch using the setreuid32() implementation
> above as a guide and include both of our names in the ChangeLog entry.
> If there are problems that I don't catch during testing, then you can
> patch my patch.
> Does this sound like a plan?

Great, Jason. 
I made small changes, latest below.


extern "C" int
setreuid32 (__uid32_t ruid, __uid32_t euid)
   int ret = 0;
   bool tried = false;
   __uid32_t old_euid = myself->uid;

   if (ruid != ILLEGAL_UID && cygheap->user.real_uid != ruid && euid != ruid)
     tried = !(ret = seteuid32 (ruid));
   if (!ret && euid != ILLEGAL_UID)
     ret = seteuid32 (euid);
   if (tried && (ret || euid == ILLEGAL_UID) && seteuid32 (old_euid))
     system_printf ("Cannot restore original euid %u", old_euid);
   if (!ret && ruid != ILLEGAL_UID)
     cygheap->user.real_uid = ruid;
   debug_printf ("real: %u, effective: %u", cygheap->user.real_uid, myself->uid);
   return ret;

More information about the Cygwin-developers mailing list