Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SUPPP导致目录所有权错误_Php_Suphp - Fatal编程技术网

Php SUPPP导致目录所有权错误

Php SUPPP导致目录所有权错误,php,suphp,Php,Suphp,[Fri Mar 11 14:48:20 2016][error][client 181.236.205.241] Application.cpp:594:目录中的SoftException /home/myuser/public\u html不属于myuser 如何修复此错误而不将目录的所有权授予myuser。它必须是另一个用户 我可以使用一些suphp.conf配置吗 编辑可以同时更改homefolder的所有权,但我不确定这是否能解决SUPPP问题 EDIT2我之所以想做这一切,是因为一个

[Fri Mar 11 14:48:20 2016][error][client 181.236.205.241] Application.cpp:594:目录中的SoftException /home/myuser/public\u html不属于myuser

如何修复此错误而不将目录的所有权授予myuser。它必须是另一个用户

我可以使用一些suphp.conf配置吗

编辑可以同时更改homefolder的所有权,但我不确定这是否能解决SUPPP问题

EDIT2我之所以想做这一切,是因为一个大网站遭到黑客攻击。其中一项措施是取消apache服务器文件夹和文件的写入权限,而不是修复整个大型应用程序。服务器不再具有写入、重命名或创建文件的权限。为此,我必须夺走文件/文件夹的所有权

我尝试过的背景:

以下是Application.cpp(从下载)中的一些代码

看起来,如果将所有者设置为超级用户(root可能是最简单的),错误可能会消失

冒着陈述显而易见的风险,命令应该是这样的

$sudo chown root/home/myuser/public\u html

编辑以在注释中添加更多与问题相关的代码

try {
    // Change working directory to script path
    API_Helper::getSystemAPI().setCwd(
        File(scriptFilename).getParentDirectory().getPath());
    if (mode == TARGETMODE_PHP) {
        std::string interpreterPath = interpreter.substr(4);
        CommandLine cline;
        cline.putArgument(interpreterPath);
        API_Helper::getSystemAPI().execute(interpreterPath, cline, env);
    } else if (mode == TARGETMODE_SELFEXECUTE) {
        CommandLine cline;
        cline.putArgument(scriptFilename);
        API_Helper::getSystemAPI().execute(scriptFilename, cline, env);
    }
} catch (SystemException& e) {
    throw SoftException("Could not execute script \"" + scriptFilename
                            + "\"", e, __FILE__, __LINE__);
}

您应该考虑网站不应该在包含敏感信息的目录中写入或重命名文件的可能性。一个很好的例子是PHP会话目录,它包含调用session_start时每个访问者的所有会话。您可以在代码文件夹之外的某个地方创建一个特殊目录,其唯一目的是存储信息。在此基础上,您可以创建一个守护进程,用于侦听网站创建的请求,该请求将处理读/写操作。@JakePsimos您可能解决了错误的问题。其想法是使文件只读,而不允许写入/重命名敏感文件。请参阅EDIT2mind快速检查:应用程序中的SoftException.cpp:576:无法执行脚本“/home/myuser/public_html/index.php”?代码正在尝试
cd
/home/myuser/public_html/
,然后执行php脚本。根据模式(参见5.Handlers)的不同,它要么尝试执行php解释器,要么将脚本本身作为cgi执行。要解决,请考虑改变模式或使用CHMOD使解释器或脚本可执行。或者,如果
cd
失败,请向您的
myuser
用户授予对目录的读取权限。我已将与此错误相关的代码块添加到回答中。我实际上必须执行以下操作:
drwxr-x--x27 root nobody 16384 Mar 11 14:59 public_html/
它必须是组中的nobody,它是这样预配置的,如果我将组更改为myuser和permission 750,那么我将获得一个`(13)权限被拒绝:/home/myuser/public\u html/.htaccess pcfg\u openfile:无法检查htaccess文件,确保它是可读的`即使
.htaccess
拥有权限644,但它肯定不是最好的公开html o+x,它肯定比我拥有的要好。也许有什么方法可以移动fix
.htaccess
?但我不知道怎么做
try {
    // Change working directory to script path
    API_Helper::getSystemAPI().setCwd(
        File(scriptFilename).getParentDirectory().getPath());
    if (mode == TARGETMODE_PHP) {
        std::string interpreterPath = interpreter.substr(4);
        CommandLine cline;
        cline.putArgument(interpreterPath);
        API_Helper::getSystemAPI().execute(interpreterPath, cline, env);
    } else if (mode == TARGETMODE_SELFEXECUTE) {
        CommandLine cline;
        cline.putArgument(scriptFilename);
        API_Helper::getSystemAPI().execute(scriptFilename, cline, env);
    }
} catch (SystemException& e) {
    throw SoftException("Could not execute script \"" + scriptFilename
                            + "\"", e, __FILE__, __LINE__);
}