[mod_python] running script with the permissions of the authenticated system user

Byron Ellacott bje at apnic.net
Fri Sep 10 11:07:06 EDT 2004


Haim Ashkenazi wrote:
> 2. the script must run as the user authenticated. I can make it run as
> root and run system commands with 'su' but I was wondering is there a
> module in python to handle it.

On UNIX systems, sys.os.set[e]uid() will allow you to set the 
(effective) user ID for the process.  If your script is running as root 
initially, you should probably use sys.os.setuid() as soon as you know 
the user you need to be.  If your script might be handling several 
requests, you'll probably need to use seteuid() instead, and revert to 
root when you're done.

-- 
bje


More information about the Mod_python mailing list