【发布时间】:2019-07-15 19:07:19
【问题描述】:
所以我在 centos7 中创建了一个 samaba 共享,我能够在 Windows 10 上读取/写入。但是,当调用 is_writable 时,我在同一 centos VM 上运行的 apache 服务器上的 PHP 脚本返回 false。
出于测试目的,我尝试将共享上的所有者设置为nobody、Apache和root,并且由于该站点是严格内部的,因此我已将权限设置为0777。我已将该文件夹移动到Apache可访问的目录中。 fileperms() 返回 16895,get_current_user() 返回 root。
if(is_writable('/var/www/html/Barcodes/') == false){
echo ' Hmm no write ';
echo fileperms('/var/www/html/Barcodes/');
chmod('/var/www/html/Barcodes/', 0777);
echo ' ';
echo fileperms('/var/www/html/Barcodes/');
echo ' '. get_current_user();
die;
}
它应该返回 true,然后我尝试在 php 中设置 perms 并测试更改,没有骰子。
编辑: 由于安全漏洞,我禁用了 SELinux,这不是真正的答案,但它确实使 php 能够在共享文件夹中读/写。所以问题归结为 chcon httpd 和 samba
【问题讨论】:
标签: php apache permissions centos7 samba