php - 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
所以:
- 触摸共享上的文件
- uid 是正确的
- dir 具有正确的权限
- 共享上的子文件夹和文件的 is_writable 返回 true
这怎么可能,只有挂载共享的根文件夹不可写,而其他所有内容都是可写的?
这是一个 ubuntu 18.04。客户端,没有运行 SELinux...
解决方案
我不认为你有40777
。我认为你有4777
或0777
使用2777
或7777
在https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits上查看更多信息
推荐阅读
- python - 为什么当我输入另一个型号(如 Model X)时,这个程序只会显示 Model S 的总价格?
- google-sheets - 谷歌表格 5000 万个单元格计数工作
- html - 在 Next.js 中,如何创建一个覆盖整个浏览器窗口的 bg 图像
- docker - Docker 无法启动守护进程:未安装设备 cgroup [Debian GNU/Linux 9 (stretch)] armv7l
- azure-functions - 从只能访问有限虚拟网络的 Azure 存储帐户订阅事件的方法是什么?
- firebase - 我可以将我的 Firebase 存储设置在与我的 Firestore 和云功能不同的区域吗?
- go - Golang Web 服务器的 Heroku 错误:Web 进程在启动后 60 秒内无法绑定到 $PORT
- javascript - Firebase:自定义声明要求我的用户注销并登录才能生效?
- xcode - "No such module 'Firebase'" // 找不到框架 FirebaseUI
- javascript - 使用 Puppeteer + Next.js 和 Express 进行网页抓取