简体   繁体   English

Apache CGI 脚本无法覆盖具有完全权限的文件

[英]Apache CGI Script Can Cannot Overwrite a file it has full permissions to

Having a weird problem on a Solaris 10 box.在 Solaris 10 机器上遇到一个奇怪的问题。 I have a cgi script (perl) which needs to overwrite a file.我有一个需要覆盖文件的 cgi 脚本 (perl)。 We do not have suexec running on Apache so the destination directory has full (777) access so that Apache can write to it.我们没有在 Apache 上运行 suexec,因此目标目录具有完全 (777) 访问权限,因此 Apache 可以对其进行写入。

The problem is that the CGI script is able to write a new file to the directory but not overwrite an existing file.问题是 CGI 脚本能够将新文件写入目录但不能覆盖现有文件。

    **Directory permissions for file destination:** 

    drwxrwxrwx 146 myuser white      32768 Jun  2 20:46 dest-dir

    **File Permissions of file that needs to be over written:** 

    -rw-r--r--   1 myuser white      0 Jun  2 20:50 cgitestfile

Anyone know a simple solution for resolving this??有谁知道解决这个问题的简单解决方案?

If you do not have +w to a file, you can't write (or overwrite) it.如果您没有 +w 文件,则无法写入(或覆盖)它。 Since you do have +w to the directory, remove the file, then recreate it.由于您确实对目录有 +w,请删除该文件,然后重新创建它。

echo "Hello" >file; #Does not work, can't +w to file!

cat file >tempfile; #works fine, +w on directory allows creating a new file 
echo "Hello" >tempfile; #Same thing
mv tempfile file; #Works because of +w on directory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM