Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-21056

Inconsistent permissions on var/autoload folder vs var/autoload/ezp_*.php

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Medium Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Caching

      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." );
                   }
               }
          }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Arnaud Lafon
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: