dqingn8836 2014-04-14 20:57
浏览 1065
已采纳

PHP chmod():不允许操作,涉及safe_mode弃用?

I'm struggling a bit to grasp the concept of chmod() from PHP as the course I'm currently taking is a bit outdated and involves safe_mode. It states that as safe_mode is turned off, the restrictions to modify permissions with chmod() to a file when the owner is not the same as the one executing the command are removed. I'm working with PHP 5.5.9 in conjuncture with XAMPP, I've verified that the flags are turned off (just in case), but can't seem to get it working. As I execute the following PHP script:

echo "File permissions :" .  decoct(fileperms("file_permissions.php"));
chmod("file_permissions.php" ,0777);

I receive the following output :

Warning: chmod(): Operation not permitted

My permissions for the file are the following

-rwxrwxrwx@  1 joelhernandez  staff     24 Apr 14 06:59 file_permissions.php

And I've executed ps aux | grep httpd to confirm that the my webserver is operating under the user "daemon" .

As I change the file ownership to daemon:

-rwxrwxrwx@  1 daemon  staff     24 Apr 14 06:59 file_permissions.php

Everything works, I do not understand why as I had understood that with safe_mode turned off, file ownership would mean nothing, instead file permissions were the way to handle access.

  • 写回答

2条回答 默认 最新

  • douzhuo8312 2014-04-14 21:13
    关注

    The daemon user is not root, so it is not allowed to change the mode of a file owned by a different user. PHP safe_mode is not the cause here. The warning is telling you that the attempted operation failed because the web server user did not have permission to make the mode change.

    The operation succeeded after you manually changed the ownership of the file to daemon because users are allowed to change the mode of files they own.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像