[sudo-users] Passing the uid sudo was run by

Matthew Hannigan mlh at zip.com.au
Wed Dec 6 01:58:51 EST 2006


On Wed, Dec 06, 2006 at 03:28:16PM +1000, Paul Stepowski wrote:
> Hi list,
> 
> I was wondering if it's possible for a script to check which user sudo was run as.

environment variable SUDO_USER

> e.g.
> 
> paul at box$ sudo ./my_script
> original uid=509(paul)
> 
> Is there any way for ./myscript to know the original uid of the user who ran
> sudo?


>  If so, can this be done in such a way that the uid cannot be manipulated
> by the user running "sudo ./myscript"?

Yeah, but of course not if ./myscript is modifiable by that 
user!

Matt




More information about the sudo-users mailing list