【问题标题】:is_writable returns false for NFS-share, even though it is writable for the user www-datais_writable 为 NFS 共享返回 false,即使它对用户 www-data 是可写的
【发布时间】:2019-07-21 03:04:15
【问题描述】:

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

文件夹作为 NFS 共享挂载为 rw 和 sec=sys。

我已经写了一个测试脚本,我也在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

所以:

  • 触摸共享上的文件有效
  • uid 正确
  • 目录具有正确的权限
  • is_writable 对于共享上的子文件夹和文件返回 true

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

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

【问题讨论】:

  • 那个文件夹的完整路径是什么?
  • @AndreiLupuleasa /var/www/html/iah/files/crm-upload
  • 根文件夹是指哪个文件夹?
  • @AndreiLupuleasa crm-upload 文件夹
  • 你能在上面做一个ls -la吗?

标签: php linux apache ubuntu nfs


【解决方案1】:

我认为你没有40777。我想你有47770777

使用27777777

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

【讨论】:

  • ls -lah 在“files/crm-upload”目录上显示:drwxrwxrwx 152 www-data www-data 4,0K Feb 27 10:26 .。此外,在 PHP 中使用sprintf('%o', fileperms($dirname)) 确定了文件权限“40777”。
猜你喜欢
  • 2015-06-03
  • 2018-11-15
  • 2012-09-07
  • 2012-06-29
  • 2013-12-12
  • 2018-02-17
  • 2012-05-11
  • 1970-01-01
  • 2015-03-18
相关资源
最近更新 更多