Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT cygwin DOT com Delivered-To: mailing list cygwin-developers AT cygwin DOT com Message-ID: <3E305C83.ECD30FB7@ieee.org> Date: Thu, 23 Jan 2003 16:20:03 -0500 From: "Pierre A. Humblet" X-Accept-Language: en,pdf MIME-Version: 1.0 To: Jason Tishler CC: cygwin-developers AT cygwin DOT com Subject: Re: setregid() and setreuid() implementation proposal References: <20030116190119 DOT GD820 AT tishler DOT net> <20030117120131 DOT GF1142 AT cygbert DOT vinschen DOT de> <20030121183105 DOT GA2128 AT tishler DOT net> <20030122104819 DOT GC29236 AT cygbert DOT vinschen DOT de> <20030122172252 DOT GA628 AT tishler DOT net> <20030122173459 DOT GM29236 AT cygbert DOT vinschen DOT de> <3 DOT 0 DOT 5 DOT 32 DOT 20030122220024 DOT 007dc9a0 AT mail DOT attbi DOT com> <20030123095002 DOT GV29236 AT cygbert DOT vinschen DOT de> <20030123122945 DOT GA1688 AT tishler DOT net> <3E2FFADF DOT 5E8E5110 AT ieee DOT org> <20030123210741 DOT GA1468 AT tishler DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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; }