[wp-trac] Re: [WordPress Trac] #6631: File and Directory Persmission are not checked by install.php

WordPress Trac wp-trac at lists.automattic.com
Mon Apr 7 13:54:28 GMT 2008


#6631: File and Directory Persmission are not checked by install.php
-------------------------+--------------------------------------------------
 Reporter:  hakre        |        Owner:  anonymous
     Type:  enhancement  |       Status:  new      
 Priority:  normal       |    Milestone:  2.5.1    
Component:  General      |      Version:           
 Severity:  normal       |   Resolution:           
 Keywords:               |  
-------------------------+--------------------------------------------------
Comment (by hakre):

 [http://de.php.net/manual/en/function.is-writable.php Somewhere On the PHP
 website], there is a function suggested to verify if a path is writeable
 or not. It workaround some known bugs already.

 {{{
 This is the latest version of is__writable() I could come up with.
 It can accept files or folders, but folders should end with a trailing
 slash! The function attempts to actually write a file, so it will
 correctly return true when a file/folder can be written to when the user
 has ACL write access to it.

 <?php
 function is__writable($path) {
 //will work in despite of Windows ACLs bug
 //NOTE: use a trailing slash for folders!!!
 //see http://bugs.php.net/bug.php?id=27609
 //see http://bugs.php.net/bug.php?id=30931

     if ($path{strlen($path)-1}=='/') // recursively return a temporary
 file path
         return is__writable($path.uniqid(mt_rand()).'.tmp');
     else if (is_dir($path))
         return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
     // check tmp file for read/write capabilities
     $rm = file_exists($path);
     $f = @fopen($path, 'a');
     if ($f===false)
         return false;
     fclose($f);
     if (!$rm)
         unlink($path);
     return true;
 }
 ?>
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/6631#comment:1>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list