njetson has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that depends on knowing the user name of the person running it. I can easily obtain this using getpwuid($>) or getlogin() or even 'whoami'.
The problem is that this script is executed by a parent script as a means of getting around a security issue using sudo.
my @script = ("sudo", "-u", "user", "/usr/local/bin/script"); system @script;
And to make matters worse this parent script sometimes gets called using a perl expect script.
What I'm trying to figure out is how I can determine the original user id for any given chain of events that causes my script to run. Wether it was nested within any number of parent scripts or if it was run using sudo -u.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Obtaining userid from script called by sudo and other scripts
by Eliya (Vicar) on Feb 14, 2012 at 21:03 UTC | |
by njetson (Initiate) on Feb 14, 2012 at 22:29 UTC | |
|
Re: Obtaining userid from script called by sudo and other scripts
by MidLifeXis (Monsignor) on Feb 15, 2012 at 13:38 UTC |