开发者

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

Having a weird problem on a Solaris 10 box. I have a cgi script (perl) which needs to overwrite a file. We do not have suexec running on Apache so the destination directory has full (777) access so that Apache can write to it.

The problem is that the CGI script is able to write a new file to the directory but not overwrite an existing file.

    **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 s开发者_Python百科imple solution for resolving this ??


If you do not have +w to a file, you can't write (or overwrite) it. Since you do have +w to the directory, remove the file, then recreate it.

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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜