PHP正在列出具有可读权限的文件,但无法一次获取或要求获取文件内容
这是一个Drupal站点,其中includes/module.inc在注册表中的文件上运行一个循环,并尝试一次。对于许多文件,这是失败的,即使文件权限正确并且文件应该是可读的PHP正在列出具有可读权限的文件,但无法一次获取或要求获取文件内容,php,drupal-6,require-once,Php,Drupal 6,Require Once,这是一个Drupal站点,其中includes/module.inc在注册表中的文件上运行一个循环,并尝试一次。对于许多文件,这是失败的,即使文件权限正确并且文件应该是可读的 # ll robots.txt -rw-r--r-- 1 6226 6226 1521 Aug 6 18:07 robots.txt 我已将调试代码添加到循环中,以输出检查文件的排列和内容: // Debug code print "$file perms:" . substr(sprintf('%o',
# ll robots.txt
-rw-r--r-- 1 6226 6226 1521 Aug 6 18:07 robots.txt
我已将调试代码添加到循环中,以输出检查文件的排列和内容:
// Debug code
print "$file perms:" . substr(sprintf('%o', fileperms($file)), -4) . "<br>";
print "$file contents:<br>" . htmlspecialchars(file_get_contents($file)) . "<hr>";
// Original Code
require_once $file;
因此,出于某种原因,./sites/default/modules/getid3/getid3.install据称具有可读性,但实际上没有
不同的路径显示不同的文件有问题:
/
./sites/default/modules/getid3/getid3.install perms:0644
/admin
./sites/default/modules/webform/components/date.inc perms:0644
/user
./sites/default/modules/cck/includes/content.crud.inc perms:0755
编辑:
请注意,./sites/default/modules/cck/includes/content.token.inc是可读的,但是./sites/default/modules/cck/includes/content.crud.inc给出了错误,下面是这些文件的目录列表,包括-context以检查SELinux
# ll --context
total 168
drwxr-xr-x 4 root root ? 4096 Sep 28 05:50 ./
drwxr-xr-x 8 root root ? 4096 Nov 6 2013 ../
-rwxr-xr-x 1 root root ? 72264 Nov 6 2013 content.admin.inc*
-rwxr-xr-x 1 root root ? 26307 Sep 28 03:13 content.crud.inc*
-rwxr-xr-x 1 root root ? 7181 Nov 6 2013 content.devel.inc*
-rwxr-xr-x 1 root root ? 3868 Nov 6 2013 content.diff.inc*
-rwxr-xr-x 1 root root ? 15914 Nov 6 2013 content.node_form.inc*
-rwxr-xr-x 1 root root ? 12550 Nov 6 2013 content.rules.inc*
-rwxr-xr-x 1 root root ? 6246 Nov 6 2013 content.token.inc*
drwxr-xr-x 3 root root ? 4096 Nov 6 2013 panels/
drwxr-xr-x 3 root root ? 4096 Nov 6 2013 views/
crud的修改日期是我在错误发生后对测试代码进行注释,但现在又回到了原来的状态
编辑2:
似乎直接访问robots.txt也是被禁止的。不确定这是否是同一个问题,但该文件看起来应该是完全可读的
# ll robots.txt
-rw-r--r-- 1 6226 6226 1521 Aug 6 18:07 robots.txt
编辑3:
看起来问题出在AppArmor上,我想这和SELinux类似。从aa enforce更改为aa Complaint解决了此问题。也许某些类似selinux的cmd可以运行此命令:
semanage fcontext -a -t httpd_httpd_sys_content_t '/var/lib/myapp(/.*)?'
restorecon -R -v /var/lib/myapp
其中/var/lib/myapp是您的./directory看起来问题出在AppArmor上,我想这与SELinux类似。从aa enforce更改为aa Complaint解决了问题。您确定文件不是空的吗?你有没有收到任何警告或错误?另外,我应该注意到,这个网站直到几天前才出现问题。它应该可以工作,所以我现在能给出的唯一解释是:seLinux:啊,是的,我也这么认为,我试过sestatus和cat/etc/sysconfig/selinux,但都暗示它没有安装?添加的ll-contextSELinux输出没有安装,所以这不意味着安装它只会增加限制吗?