views:

256

answers:

1

I have Apache/2.2.11 using mod_python 3.3.1/Python 2.5 running under Gentoo linux. In my python script I invoke a win32 exe using wine (os.popen2 call). This works fine outside of Apache but under mod_python I get:

wine: cannot open /root/.wine : Permission denied

in /var/log/apache/error_log. My apache install is not running as the root user/group. Any ideas why it's looking into /root/.wine?

Thanks,

LarsenMTL

+3  A: 

It's probably because $HOME isn't set correctly...

Btw. Are you really sure invoking wine from mod_python is a good idea?

If you are sure, something like that could work...

from subprocess import Popen        

HOME = '/the/home/of/www-data' #PLEASE edit
proc = Popen(cmd, shell=False, stdin=PIPE,
             stdout=PIPE, stderr=PIPE, close_fds=True,
             cwd=HOME, env={"HOME":HOME)
Johannes Weiß
Thanks Johannes. Your answer lead me to this: http://stackoverflow.com/questions/133860/running-subversion-under-apache-and-modpython. I hacked the /etc/init.d/apache file to set $HOME properly.
Mark
Oh, and using wine from mod_python is a horrible, horrible idea. Too much legacy code. It's on the schedule to be re-written, but I'm sure know how schedules slip and slide.
Mark
:-) I would rather not hack /etc/init.d/apache since after a distro upgrade it could be reset... I think it's better to set it when using Popen. So another process spawned can not override it...
Johannes Weiß