On 5/2/19 8:04 AM, Ted Unangst wrote:
> Nick Holland wrote:
>> > In a shell script invoked by doas, is it possible to find which user
>> > invoke the script? my search a the moment has come up empty.
>> 
>> most likely place would be an environment variable, right?
> 
>> 
>>     # echo "I started out as $LOGNAME"
>>     I started out as nick
> 
> Note that LOGNAME and other variables can be set by the user to indicate a
> different user name.
> 
> $ env LOGNAME=somebody doas sh -c 'echo $LOGNAME'
> somebody

And that's important -- I (silently) assumed a semi-friendly
environment, not a good idea.  Evaluate my suggestion based on your
actual needs and risks.

But then, if the wrong person has sudo access on your box, this may not
be your biggest problem of the day.

Nick.

Reply via email to