Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Silence compilation warnings about setuid, setgid



On Wed, Jun 13, 2018 at 6:10 AM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Wed, 13 Jun 2018 04:49:39 -0700
> Eitan Adler <lists@xxxxxxxxxxxxxx> wrote:
>>
>> setgid must be called before setuid. If setuid is called first, on
>> some platforms, it no longer has privs to call setgid aymore.
>
> Presumably that's a trivial swap?  I don't know if we need both
> setgid()s before both setuid()s, because I don't know why they're
> repeated --- but if the second case is simply to test for an error that's
> not a big deal since if it worked properly there won't be one.

IIRC there are some cases in which setgid/setuid fail silently, i.e.,
without changing anything but without setting errno.  The second calls
are to double-check that the first one was not rogue in that way.

This may have been isolated to a 1990s-era OS that is no longer at
issue.  Either way there's no particular reason to save and report
errno from the first call.



Messages sorted by: Reverse Date, Date, Thread, Author