I have read somewhere that we always should change $EGID before $EUID
Can you track down where you read that?
It isn't obvious to me that this is a bug in perl: in the list-assignment case, we drop privileges (by setting a non-root EUID) before trying to set EGID; it does not seem unreasonable to me that the attempt to set EGID then fails.
However I can also see the argument (particularly if you can find the above reference) that for list assignment perl should choose to modify groups before users, either always or only in specific (documented) cases.
And certainly if perl is correct to treat this the way it does, then it is wrong to recommend the code it does in perlsec.
Sadly I cannot readily test any of this, since on my Ubuntu system the set[ug]id bits are ignored for scripts. I do think it is worth opening an issue on github for this specific aspect of the perlsec code.
In reply to Re^2: Not understanding the code to drop privileges in perlsec
by Anonymous Monk
in thread Not understanding the code to drop privileges in perlsec
by Nocturnus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |