Reputation: 137
In Linux, need to write a shell script which can be ran as other users (via doas permissions for this one script), but I need to know in the script who ran it originally. How would I go about doing this?
Upvotes: 0
Views: 49
Reputation: 781096
From the man page
By default, a new environment is created. The variables
HOME
,LOGNAME
,PATH
,SHELL
, andUSER
and the umask(2) are set to values appropriate for the target user.DOAS_USER
is set to the name of the user executingdoas
.
So use $DOAS_USER
to get the original username.
Upvotes: 1