Problèmes de droits sur dokuwiki: fixed

J'ai écrit sur twitter

trying to remove dokuwiki dirs created by php on a server where I'm not root… grrr! 8:18 AM May 11th, 2009 via web

moins de deux heures plus tard, dokuwiki me répondait sur twitter avec la solution:

splitbrain@fradeff http://bit.ly/HfkXw 9:42 AM May 11th, 2009 via web in reply to fradeff

Depuis, je trouve twitter juste magique! J'ai testé ce script, il marche parfaitement (site de partenaires qui buggait suite à un upgrade avec des problèmes de permissions, sans accès root donc pas de chmod possible sur l'uid apache)

source de ce script: twitter / http://www.dokuwiki.org/tips:fixperms.php


When DokuWiki creates a file it is owned by the webserver. When the permissions are set very restrictive and you only have FTP access it may mean you will be unable to delete DokuWiki created files. The following script will help you to regain control by chmod'ing all files and directories to be writable by everyone. Simply drop it into your DokuWiki directory via FTP and run it by opening it in your Browser.

:!: Only use this script if you know what you're doing.

fixperms.php
    <?php
    /**
     * When you call this file it will make all files and directories
     * in it's own directory and all directories below writable by
     * everyone
     *
     * You can use this to (re)gain control on files owned by the
     * apache process.
     *
     * Only use it if you really know that this is what you want.
     * Delete the file immediately after using it!
     */
 
    header("Content-Type: text/plain");
 
    echo "starting...\n";
    flush();
    traverse(dirname(__FILE__));
    echo "finished...\n";
 
    function traverse($dir){
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                //skip hidden files and upper dirs
                if(preg_match('/^[\._]/',$file)) continue;
                if(is_dir($dir.'/'.$file)){
                    if(@chmod($dir.'/'.$file,0777)){
                        echo "chmod 0777 $dir/$file OK\n";
                    }else{
                        echo "chmod 0777 $dir/$file FAILED\n";
                    }
                    flush();
                    traverse($dir.'/'.$file);
                    continue;
                }
                if(@chmod($dir.'/'.$file,0666)){
                    echo "chmod 0666 $dir/$file OK\n";
                }else{
                    echo "chmod 0666 $dir/$file FAILED\n";
                }
                flush();
           }
           closedir($dh);
       }
    }
    ?>
  • info/fixperms.php.txt
  • Dernière modification: 2018/07/18 09:45
  • par radeff