首页 > 解决方案 > is_writable 为 NFS 共享返回 false,即使它对用户 www-data 是可写的

问题描述

我有一个相对文件夹“files/crm-upload”,我想在其中上传文件。我的代码检查 is_writable() 是否为真,只有在这种情况下才会继续。

该文件夹安装为具有 rw 和 sec=sys 的 NFS 共享。

我写了一个测试脚本,我也在 apache 上执行它来查看访问权限,结果是:

files/crm-upload/php_touch modification time has been changed to present time 
My effective UID is 33 but my UID is really 33
files/crm-upload/ is owned by 33 and has permissions 40777
is_readable('files/crm-upload/') gives true
is_readable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/') gives false
is_writable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/25/') gives true
is_writable('files/images/') gives true
file_exists('files/crm-upload/') gives true
file_exists('files/crm-upload/php_touch') gives true
Some stat uids: 

files/crm-upload/: 33
files/crm-upload/php_touch: 33
files/images/: 33

所以:

这怎么可能,只有挂载共享的根文件夹不可写,而其他所有内容都是可写的?

这是一个 ubuntu 18.04。客户端,没有运行 SELinux...

标签: phplinuxapacheubuntunfs

解决方案


我不认为你有40777。我认为你有47770777

使用27777777

在https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits上查看更多信息


推荐阅读