PHP是否阻塞了粘滞位? [英] Is PHP blocking the sticky bit?

查看:61
本文介绍了PHP是否阻塞了粘滞位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将PHP的chmod的权限设置为02775.但是由于某种原因,它仅向文件中添加了0775.我以为这可能是PHP的chmod实现或其他问题,所以我尝试使用PHP的passthru()函数运行"chmod 02775 path",但是得到了相同的结果.我在shell中尝试了相同的命令,并且效果很好.我使用root用户以CLI身份运行脚本,所以这不是用户限制问题.

I tried setting a permission with PHP's chmod to 02775. But for some reason it only added 0775 to the file. I thought it might be a problem with PHP's chmod implementation or something, so I tried running 'chmod 02775 path' using PHP's passthru() function, but I got the same result. I tried the same command in a shell and it worked perfectly. I ran the script as CLI using root, so it's not a user restriction issue.

我能提出的唯一理由是,PHP是否以某种方式在受控环境中运行?否则,passthru()至少应该起作用了.

The only reason that I can come up with, is that PHP is somehow running in a controlled environment? Otherwise the passthru() should at least have worked.

推荐答案

好的,发现了问题. 适当地,PHP的chown()和chgrp()函数会将sticky位重置为0.因此,chmod()必须是最后一个要调用的命令,以保留权限.

Okay found the problem. Apprently PHP's chown() and chgrp() functions resets the sticky bit to 0. So chmod() must be the last to be called in order to preserve the permissions.

这篇关于PHP是否阻塞了粘滞位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆