【问题标题】:Why my php-script executed when file permissions only read and write?为什么我的 php 脚本在文件权限只能读写时执行?
【发布时间】:2014-10-19 06:30:25
【问题描述】:

我的名字 lebnik,以及关于我的信息:

# id lebnik
uid=1000(lebnik) gid=1000(lebnik) groups=1000(lebnik),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)

我的网络服务器 Apache 从用户 www-data 运行 php-scripts,检查一下:

root@debian /etc/apache2 # grep -R "APACHE_RUN_USER=" .
./envvars:export APACHE_RUN_USER=www-data

关于用户 www-data 的信息:

# id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)

我创建 php-script file.php:

<?php
error_reporting(E_ALL);
ini_set('display_errors',1);

echo 'script executed';
?>

接下来,我检查我的 file.php 的权限

# ls -la
total 16
drwxrwxrwx 1 www-data www-data 4096 Oct 18 00:49 .
drwxrwxr-x 1 www-data www-data 4096 Oct 18 00:36 ..
-rw-rw-r-- 1 www-data www-data  225 Oct 18 00:46 file.php

我尝试使用 Apache 调用我的脚本: curl http://starsite.l/file.php 并查看:

script executed

为什么我的php-script在文件权限只能读写时执行?

【问题讨论】:

    标签: php apache curl


    【解决方案1】:

    执行权限会阻止 shell 执行文件,但不会阻止另一个应用程序读取文本文件并执行它。 php引擎不关心可执行权限位。

    【讨论】:

      猜你喜欢
      • 2012-07-01
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      • 1970-01-01
      • 2016-10-11
      • 1970-01-01
      • 2021-07-18
      • 2011-11-15
      相关资源
      最近更新 更多