[mod_python] Porting from python cgi module - with backwards compatibility

Jim Ramsay lists at jimramsay.com
Wed Jan 21 14:50:23 EST 2004

I have a python program (tmda-cgi - http://www.tmda.net/tmda-cgi/) which 
I would like to start working with mod_python if possible, but I need to 
know two things:

1 - Depending on the configuration, some people run this script SUID 
root, as it must os.setuid() to other users.  Is it possible to do this 
with mod_python?  Or only if root runs the apache server?

2 - To get around this (and the fact that scripts themselves can't be 
executed SUID) in the existing implementation, we have written a tiny C 
wrapper which is SUID, which then loads the python interpreter which 
runs the real python program, which imports and uses the 'cgi' module. 
Is it possible (or easy) to write a mod_python wrapper which imports and 
executes this existing program without changing the existing program?

If it's not possible to do (1), at least the configurations which don't 
require the SUID functionality could run under mod_python with the 
wrapper in (2).

I saw an old archived email which suggested that:

os.env = req.subprocess_env

in a handler just before I run the existing methods would do it.  Is 
this still the case?  Will it work for both GET and POST HTTP methods?

Jim Ramsay
"Me fail English?  That's unpossible!"

More information about the Mod_python mailing list