How do I execute a command as the original user from a sudo'd program? How do I execute a command as the original user from a sudo'd program? unix unix

How do I execute a command as the original user from a sudo'd program?


The sudo manual shows that $SUDO_USER should give you the original user's username and $SUDO_UID gives the original user's UID.


I had this problem with Samba on a NAS while creating files from a web-application.

In this case I retrieved the running processes and determined which user was running samba.After isolating that name, I had the correct user account. Maybe this will work for your situation as well?

In this case I imagine you need to filter through the ps output and lookup the name of your program. See if that works by testing it on bash.