How to get the name of the user that launched `sudo`
When you fire off something with sudo
a couple of environment variables get set, specifically I think you are looking for SUDO_UID
. These should be accessible to any program running through the usual channels of accessing environment variables.
You can see the other things set by cheating like this from a shell: sudo env | grep SUDO