Search code examples
pythonapachemod-pythonwine

Invoking Wine From Apache


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?


Solution

  • 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)