Details
-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
Description
In eZAutoloadGenerator, 'var/autoload' is created with mkdir which takes the current umask into account. Even if you have EZP_INI_FILE_PERMISSION = 0777, this might lead to a folder with 755 permissions which is not consistent with the permissions of the php files within the folder (which are chmod'ed just after being written).
Solution 1 :
Use $oldmask = umask(0); before and reset it with umask( $oldmask ); just after the mkdir can do the trick but that's not a good practice (see the Note in http://www.php.net/manual/en/function.umask.php)
Solution 2 :
Just trigger a chmod after the mkdir
protected function writeAutoloadFiles() { $directorySeparators = "/\\"; foreach( $this->autoloadArrays as $location => $data ) { if ( $this->options->outputDir ) { $targetBasedir = rtrim( $this->options->outputDir, $directorySeparators ); } else { $targetBasedir = $this->targetTable( $location ); } if( file_exists( $targetBasedir ) && !is_dir( $targetBasedir ) ) { throw new Exception( "Specified target: {$targetBasedir} is not a directory." ); } else if ( !file_exists( $targetBasedir ) ) { if ( defined( 'EZP_INI_FILE_PERMISSION' ) ) { mkdir( $targetBasedir, EZP_INI_FILE_PERMISSION, true ); chmod( $targetBasedir, EZP_INI_FILE_PERMISSION ); } else { mkdir( $targetBasedir, 0777, true ); chmod( $targetBasedir, 0777 ); } } $filename = $this->nameTable( $location ); $filePath = $targetBasedir . DIRECTORY_SEPARATOR . $filename; $file = fopen( $filePath, "w+" ); if ( $file ) { fwrite( $file, $this->dumpArrayStart( $location ) ); fwrite( $file, $data ); fwrite( $file, $this->dumpArrayEnd() ); fclose( $file ); if ( defined( 'EZP_INI_FILE_PERMISSION' ) ) { chmod( $filePath, EZP_INI_FILE_PERMISSION ); } else { chmod( $filePath, 0777 ); } } else { throw new Exception( __METHOD__ . ": The file {$filePath} is not writable by the system." ); } } }