0xbeef has asked for the wisdom of the Perl Monks concerning the following question:
I have run into a peculiarity when using the $> variable to demote privileges in one of my programs, which can be simplified to:
This tested fine on my Linux system, the idea being that I would demote myself to nobody (uid 65534) before doing some system calls.sub DropPriv($uid,$groups) { $) = $groups; $> = $uid; if ($> != $uid) { print STDERR "demotion to $uid failed, EUID=$>.\n"; return 0; } return 1; }
The same code unexpectedly failed on my AIX system with a resulting EUID=-2, which I'm now guessing to be related to an overflow problem since the only difference on AIX is that nobody's uid is 4294967294 by default. When I use a user with a lower uid it works fine.
The AIX system is running v5.8.0, but I got the same result on v5.8.8.
My workaround was to use the "sys" user (uid=3), but can anyone confirm this as an overflow issue with the built-in $> variable and perhaps an alternative solution?
Niel
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: EUID cannot be set
by bluto (Curate) on May 09, 2007 at 22:55 UTC | |
|
Re: EUID cannot be set
by mattr (Curate) on May 10, 2007 at 06:17 UTC | |
|
Re: EUID cannot be set
by jettero (Monsignor) on May 09, 2007 at 21:19 UTC | |
by 0xbeef (Hermit) on May 09, 2007 at 21:34 UTC | |
by mr_mischief (Monsignor) on May 10, 2007 at 20:19 UTC | |
|
Re: EUID cannot be set
by AK108 (Friar) on May 10, 2007 at 03:18 UTC | |
by 0xbeef (Hermit) on May 10, 2007 at 15:37 UTC |