0.6.1.20060928-1 release
[manu/suphp.git] / src / Application.cpp
index dd2a02e..bb7ce50 100644 (file)
@@ -89,6 +89,12 @@ int suPHP::Application::run(CommandLine& cmdline, Environment& env) {
 
        this->checkScriptFile(scriptFilename, config, env);
 
+       // Root privileges are needed for chroot()
+       // so do this before changing process permissions
+       if (config.getChrootPath().length() > 0) {
+           api.chroot(config.getChrootPath());
+       }
+
        this->changeProcessPermissions(scriptFilename, config, env);
 
        interpreter = this->getInterpreter(env, config);
@@ -97,6 +103,12 @@ int suPHP::Application::run(CommandLine& cmdline, Environment& env) {
        // Prepare environment for new process
        newEnv = this->prepareEnvironment(env, config, targetMode);
        
+       // Set PATH_TRANSLATED to SCRIPT_FILENAME, otherwise
+       // the PHP interpreter will not be able to find the script
+       if (targetMode == TARGETMODE_PHP && newEnv.hasVar("PATH_TRANSLATED")) {
+           newEnv.setVar("PATH_TRANSLATED", scriptFilename);
+       }
+       
        // Log attempt to execute script
        logger.logInfo("Executing \"" + scriptFilename + "\" as UID "
                       + Util::intToStr(api.getEffectiveProcessUser().getUid())