I have a bash shell script that must be run as root. If a user launches it they are asked for the root password and the script is rerun in a subshell. ./$0 &
Let's say a user named 'John' launches the script. After he provides the root password the script is rerun as root, but how can i tell who originally launched the script (John) from within the script itself? At the moment I am dumping a file with the original launcher which I can reference later but this is ugly.
Other options I considered are using the process list but again, there must be a more elgant solution.
GNU bash, version 4.2.45(2)-release (x86_64-slackware-linux-gnu)