【问题标题】:Apache CGI Script Can Cannot Overwrite a file it has full permissions toApache CGI 脚本无法覆盖它拥有完全权限的文件
【发布时间】:2011-06-02 21:00:01
【问题描述】:

在 Solaris 10 机器上遇到一个奇怪的问题。我有一个需要覆盖文件的 cgi 脚本 (perl)。我们没有在 Apache 上运行 suexec,因此目标目录具有完全 (777) 访问权限,以便 Apache 可以对其进行写入。

问题在于 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

有人知道解决这个问题的简单解决方案吗?

【问题讨论】:

    标签: apache permissions cgi


    【解决方案1】:

    如果你没有 +w 到一个文件,你不能写(或覆盖)它。由于您确实对目录有 +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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-26
      • 2011-06-25
      • 2014-08-19
      • 2019-09-18
      • 1970-01-01
      • 2019-09-13
      • 2023-03-18
      • 1970-01-01
      相关资源
      最近更新 更多