prowler has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently trying to set the effective uid and gid to match the owner of a particular file as indicated by stat(), unfortunately it isn't working properly.
When I set the two values separately (gid first) it works as desired (setting the uid first doesn't allow the gid to change), but setting the variables at the same time doesn't set the egid properly.
Initial settings:
$uid = 99; # $> = 0 $gid = "99 2 99"; # $) = "0 1 0"
1) Separately - uid first
$> = $uid; $) = $gid; # Current values are now: # $> = 99 # $) = "0 1 0"
2) Separately - gid first
$) = $gid; $> = $uid; # Current values are now: # $> = 99 # $) = "99 2 99" # Which is the desired outcome
3) Single assignment
($>, $)) = ($uid, $gid;) # Current values are now: # $> = 99 # $) = "0 99 2" # The other groups section has been successfully changed, # but the actual effective gid has not.
Attempt 3) has the same outcome if both lists are reversed at the assignment stage.
Is it somehow possible to assign to the effective gid and uid at the same time? Obviously I can split it into two steps, but I would prefer to assign both at once if possible (and this seems a strange way to behave).
EDIT
This is Perl 5.8.0 running on Redhat 9
Prowler
- Spelling is a demanding task that requies you full attention.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Setting EUID & EGID in one step
by Fletch (Bishop) on Oct 28, 2004 at 11:07 UTC |