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

Haim Ashkenazi haim at babysnakes.org
Fri Sep 10 05:11:26 EDT 2004

On Fri, 10 Sep 2004 03:21:23 +0300, Haim Ashkenazi wrote:

> On Fri, 10 Sep 2004 10:07:06 +1000, Byron Ellacott wrote:
>> 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.
> great, that's what I was looking for. to revert to root do I use seteuid()
> again?
ok, that was just me being lazy :(
I can seteuid() back and forth so I guess that's the answer...
also, found a nice solution to the authentication problem in the
activestate cookbook - I can authenticate through pop3...


More information about the Mod_python mailing list