|P is for Practical|
Re^2: Request for comments - Proc::UIDby pjf (Curate)
|on Jun 09, 2004 at 03:18 UTC||Need Help??|
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,
Perl Training Australia