开发者

Detect the minimum permissions PHP needs to write to a directory: 0777, 0770 or 0700?

开发者 https://www.devze.com 2023-01-09 02:33 出处:网络
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

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:

开发者_运维百科
  1. PHP user = user FTP. Thus, writing needs 0700
  2. The user is different, but it belongs to the same group. It's 0770
  3. 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.


posix_access()

0

精彩评论

暂无评论...
验证码 换一张
取 消