Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
XY problem? Do you really need to know what came on the left hand side of "perl" on the command line, or is your goal to determine whether you're running as a particular user, with certain permissions, or do you need to know if you're running with different real and effective user or group ID's? For what it's worth, when operating under 'sudo', the environment variable $ENV{USER} will contain the login of the person who invoked sudo, and $ENV{SUDO_USER} will contain the login of the sudo target user (typically root, unless configured for some other user or otherwise specified). Sudo does set both real and effective uid and gid to the target user/group, so it wouldn't do any good detecting a mismatch there. But by detecting the USER adn SUDO_USER mismatch, you can detect sudo's effects. So you could just check for the existence of $ENV{SUDO_USER}, or possibly, for $ENV{USER} and $ENV{SUDO_USER} to disagree. If either of those cases occur, you're probably running under sudo. ('probably', unless someone went to the trouble of tampering with those variables -- though I can't think of any reason why someone might.) Dave In reply to Re: Problem in command line arguements
by davido
|
|