This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: setregid() and setreuid() implementation proposal


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.

Pierre

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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]