谁拥有 php exec tar 提取的文件?
就文件权限而言,当您使用 php 脚本解压 tar 文件时,创建的文件的“所有者”用户是谁?
我想知道是否是我的 ftp 用户,因为我上传了脚本文件?或者 apache 拥有该文件吗?我知道它们的标志被设置为保留我不想要的原始权限(由其他人创建和存档的文件)。我希望我的用户成为文件的创建者/所有者。
PS 它是一个云环境。 下面是我上传的代码。我通过在浏览器中访问该页面来执行。我可以在 Dreamweaver 中更改文件权限...这是否意味着我是所有者?
exec('wget http://wordpress.org/latest.tar.gz ');
exec('tar -xzvflatest.tar.gz');
As far as file permissions are concerned, when you use a php script to unzip a tar file, who is the "owner" user of the files created?
I'm wondering if its my ftp user because I uploaded the script file? Or does apache own the file? I know their are flags to be set to preserve the original permissions which I don't want (files where created and archived by someone else). I want my user to be the creater/owner of the files.
PS Its a cloud environment.
Below is the code I uploaded. I executed by visiting the page in a browser. I can change file permissions in Dreamweaver... Does that mean I am owner?
exec('wget http://wordpress.org/latest.tar.gz');
exec('tar -xzvf latest.tar.gz');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果从 apache 运行,最有可能的是 apache 运行的用户。
Most likely, if run from apache, the user that apache is running as.
无论用户运行 PHP。它可以是 Web 服务器的系统用户名,也可以是 Webroot 的所有者(通过 suexec)。如果由服务器拥有,则可能是
nobody
或www-data
。最重要的是用户PHP(服务器端)正在以什么身份运行。 试试这个来找出答案。
Whatever user runs PHP. Its either the web server's system user name, or the owner of the webroot (through suexec). If owned by the server, its likely
nobody
orwww-data
.What matters most is what user PHP (server side) is running as. Try this to find out.
您可以执行
echo shell_exec('whoami');
这将输出用户的名称。对我来说,它输出了 apache
,是的,apache 将拥有这些文件。例如,如果您以 root 身份执行以下操作:
You can do
echo shell_exec('whoami');
And that will output the name of the user. For me, it outputted
apache
And yes, apache will own the files. For example, if you do something like this as root: