develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #96208] UIDs and GIDs should not be cached

Thread Previous | Thread Next
From:
Ævar Arnfjörð Bjarmason
Date:
February 11, 2012 12:42
Subject:
Re: [perl #96208] UIDs and GIDs should not be cached
Message ID:
CACBZZX4MCnwdVOAfn=fOBTHhc3tP9pda4T+oUybQwSO5SRx+AA@mail.gmail.com
On Sat, Feb 11, 2012 at 20:45, Leon Timmermans <fawaka@gmail.com> wrote:
> On Sun, Jan 15, 2012 at 10:07 PM, Leon Timmermans <fawaka@gmail.com> wrote:
>> Third attempt. I really should stop coding for tonight.
>
> Fix attached. I couldn't remove the cache entirely, as it's also used
> by the ID swapping, but now every read of $<, $>, $( or $) always
> returns the correct result.

I very much like where this patch is going, but IMO it needs some
improvement:

 * You've changed it so that we now return the current and correct
   values when getting $<, $>, $( and $), but there's still a lot of
   places in the perl core where we're looking at PL_uid and pals,
   these should be changed to call PerlProc_getuid et al instead.

 * Since the id swapping is only used by "PL_delaymagic &= ~DM_RUID;"
   and pp_sassign (and variants) we should just add new a new
   PL_delaymagic_uid variable that's only used by the set() magic and
   sassign().

   This variable should not be made public. Thus programs on the CPAN
   that expect to assign to PL_uid would fail and would need to be
   updated, but they wouldn't contain a logic error anymore (by
   expecting the core to read from PL_uid).

 * Code like the code in this ifdef in POSIX.xs can just go away:

    SysRet
    setuid(uid)
            Uid_t           uid
        CLEANUP:
    #ifndef WIN32
            if (RETVAL >= 0) {
                PL_uid  = getuid();
                PL_euid = geteuid();
            }
    #endif

 * It would also be informative to check how much of the CPAN is
   relying on PL_uid, but I don't think that should block this going
   in.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About