Doesn't that mean that if I use English and use Proc::UID qw(:vars) then there might be issues as to which $E[UG]ID I'm using? (Although you could argue that I'd get what I deserved).

Yes, using both English and Proc::UID qw(:vars) will result in both trying to export $EUID and $EGID. You'll get the variables from the last module used.

If you want to avoid this ambiguity, you can choose to refer to the Proc::UID variables by their full names: $Proc::UID::EUID and $Proc::UID::EGID. This will always work, even if you didn't use the qw(:vars) option of Proc::UID.

The main difference between the Proc::UID versions and the English/native versions of the variables is that the Proc::UID is that the native variables can be return cached (incorrect) data, and also fail silently if you attempt to set them and fail. Proc::UID variables on the other hand will always check the current privileges, and will always throw an exception if you alter your privileges in a way the operating system does not allow.

One final difference is that Proc::UID's group-id variables don't contain information from getgroups(), whereas $( and $) contain this information when evaluated as strings. This may change before the code is released as stable, but probably won't, as I feel it works againt the goal of 'simplicity'. If anything, a new interface will be made to allow access to getgroups() / setgroups(). It will almost certainly use arrays to return/set the supplimentary groups, as this is much more sensible than expecting the user to split, sort, mangle, and join supplimental groups each time.

As for Perl's special variables caching information, Perl internally uses the interal variables PL_uid PL_euid PL_gid and PL_egid to record the program's current privileges. These are set on program start-up, and are refreshed after certain operations, such as assigning to $>, or (with more recent Perls) calling the POSIX::setuid function. They're not updated after a call to syscall(), and not updated in XS-land unless the code does so explicitly. As such if you're calling privilege-changing calls directly, it's possible for a program that's running with one set of privileges to appear to be running with a different set by Perl. Obviously that's a Bad Thing.

Getting Perl's native special variables to be more forthcoming about checking the real privileges is another goal of mine, but can be done indepedently of my work on Proc::UID.

All the very best,


In reply to Re^2: Request for comments - Proc::UID by pjf
in thread Request for comments - Proc::UID by pjf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.