检测 PHP 写入目录所需的最低权限:0777、0770 或 0700?
想象一些脚本&其文件夹是通过 FTP 上传的。通常,文件夹权限是错误的,脚本应该建议设置哪些权限。当然,将我要写入的所有内容都设置为 0777 并不好。但有 3 种可能的 Web 服务器配置:
- PHP 用户 = 用户 FTP。这样,写入需要 0700
- 用户不同,但属于同一个组。它是 0770
- PHP 从
nobody
运行,或者没有通用 GID:它是 0777
有没有办法检测哪些权限八位字节足以让脚本运行?
PCNTL 扩展不受欢迎,因为某些配置缺少它。
Imagine some script & its folders was uploaded with FTP. Usually, the folder permissions are wrong and the script should suggest which permissions to set. Certainly, it's not good to set 0777 for everything I'm going to write to. But there're 3 possible webserver configurations:
- PHP user = user FTP. Thus, writing needs 0700
- The user is different, but it belongs to the same group. It's 0770
- PHP runs from
nobody
or there's no common GID: it's 0777
Is there a way to detect what permissions octets are enough for the script to function?
The PCNTL extension is not welcome because some configurations lack it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
posix_access()
posix_access()