php - rmdir() bug with particular filename? Permission denied -


first, let's these out of way:

  • there no open handles on directory.
  • there no files in directory.
  • chmod ing permissions 0777 not prevent error.
  • the directory name correct.

now then, here's problem. rmdir() throwing error when trying delete directory:

rmdir(098f6bcd4621d373cade4e832627b4f6) [function.rmdir]: permission denied in path\to\administrate.php on line 124

098f6bcd4621d373cade4e832627b4f6 name of directory.

here relevant portion of script.

if(is_dir($userhash)) : foreach (new directoryiterator($userhash) $fileinfo) {     $filename = $fileinfo->getfilename();     if($fileinfo->isdot()) continue;      if(!rename($userhash.'/'.$filename , 'trashcan/'.$username.'/'.$filename)) {         echo '<p class="error">could not move '.$filename.'</p>';         $err = 1;     } } else :     echo '<p class="error">unable delete files! error: 67</p>';     $err = 1; endif;      //just sure     chmod('./',0777);     chmod($userhash,0777);  // rmdir once dir empty. if(rmdir($userhash))     echo '<p class="success">deleted user directory. files in trash.</p>'; else {     echo '<p class="error">could not remove user directory. error: 656</p>';     $err = 1; } 

update

i manually created dir 'jake' in same directory. did rmdir('jake'); , worked great. now, manually created dir '098f6bcd4621d373cade4e832627b4f6' in same directory. did rmdir('098f6bcd4621d373cade4e832627b4f6'); , errored!

update 2

this beginning weird rmdir() bug, unlikely seems. here directory names i've created , tried remove rmdir;

098f6bcd4621d373cade4e832627b4f6        |  didn't work (quintuple checked) 098f6bcd4621d373cade4e832627b4f7        |  worked 098f6bcd4621d373cade4e832627b4f         |  worked 098f6bcd4621d373cade4e832627b4f66       |  worked 

in order able remove file:

  • user should have write permissions parent directory
  • restricted deletion flag should not set parent directory

update: restricted deletion flag - man chmod:

restricted deletion flag or sticky bit

the restricted deletion flag or sticky bit single bit, interpretation depends on file type. directories, prevents unprivi‐leged users removing or renaming file in directory unless own file or directory; called restricted deletion flag directory, , commonly found on world-writable directories /tmp. regular files on older systems, bit saves program's text image on swap device load more when run; called sticky bit.

you may set adding 1 first octal digit in mode, example:

chmod 1xxx dirname 

update 2:

does user, under php executed, has permissions chmod parent directory?

in other words, sure first chmod call returns true?

chmod('./',0777); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -