in reply to how to switch user
If you want to go from root to a normal user, that's easy. Just drop $EUID/$EGID to your real $UID/$GID (respecitivily):
use English; # For saner var names # Do some stuff as root $EUID = $UID; $EGID = $GID; # Now we're running as a normal user
Going up in privileges is harder. Probably the only realistic option is to execute the actual su (or maybe sudo) command and feed it the data to execute. (On GNU/Linux, you can pass in the data via the '-c' option to su, but this isn't portable).
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: how to switch user
by bluto (Curate) on Jun 23, 2003 at 15:44 UTC |