From 642127547acbc91f2cb864c3d4880ce4998a9bc4 Mon Sep 17 00:00:00 2001 From: Dale Sikkema <dsikkema@ebay.com> Date: Sat, 19 Mar 2016 19:58:10 -0500 Subject: [PATCH] MAGETWO-50284: stop controlling FS permissions on application level --- app/bootstrap.php | 1 - .../Magento/Backup/Model/Fs/Collection.php | 1 - app/code/Magento/Captcha/Helper/Data.php | 2 - .../Model/Product/Gallery/Processor.php | 1 - app/code/Magento/Deploy/Model/Filesystem.php | 17 ++++--- app/code/Magento/Deploy/Model/Mode.php | 1 - .../Magento/Translation/Model/FileManager.php | 5 +-- .../Util/Generate/Factory/AbstractFactory.php | 4 +- .../Magento/TestFramework/Application.php | 2 +- .../Cms/Model/Wysiwyg/Images/StorageTest.php | 2 +- .../Filesystem/Directory/WriteTest.php | 44 +++++++++---------- .../Framework/Filesystem/Driver/FileTest.php | 2 +- .../Test/Integrity/Di/CompilerTest.php | 5 +-- .../Magento/Test/Js/Exemplar/JsHintTest.php | 2 +- .../Magento/Test/Js/LiveCodeTest.php | 2 +- .../Magento/Test/Php/LiveCodeTest.php | 2 +- .../Framework/App/Cache/Frontend/Factory.php | 3 +- .../Magento/Framework/Archive/Helper/File.php | 4 +- .../Magento/Framework/Archive/Tar.php | 2 +- .../Magento/Framework/Backup/Filesystem.php | 2 +- .../Backup/Filesystem/Rollback/Ftp.php | 2 +- .../Magento/Framework/Code/Generator/Io.php | 2 +- .../Magento/Framework/File/Uploader.php | 7 +-- .../Framework/Filesystem/Directory/Write.php | 2 +- .../Framework/Filesystem/Driver/File.php | 4 +- .../Framework/Filesystem/DriverInterface.php | 6 ++- .../Magento/Framework/Filesystem/Io/File.php | 4 +- .../Magento/Framework/Filesystem/Io/Ftp.php | 2 +- .../Framework/Filesystem/Io/IoInterface.php | 2 +- .../Magento/Framework/Filesystem/Io/Sftp.php | 2 +- .../Magento/Framework/Logger/Handler/Base.php | 2 +- .../Framework/Setup/BackupRollback.php | 4 +- .../Setup/Test/Unit/BackupRollbackTest.php | 4 +- .../Magento/Framework/System/Dirs.php | 2 +- lib/internal/Magento/Framework/System/Ftp.php | 4 +- pub/errors/processor.php | 3 +- .../Command/DiCompileMultiTenantCommand.php | 4 +- .../Setup/Model/MarketplaceManager.php | 4 -- .../Di/Compiler/Config/Writer/Filesystem.php | 2 +- .../I18n/Pack/Writer/File/AbstractFile.php | 2 +- 40 files changed, 79 insertions(+), 89 deletions(-) diff --git a/app/bootstrap.php b/app/bootstrap.php index 63fe76b4562..51fe7bf3cd9 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -9,7 +9,6 @@ */ error_reporting(E_ALL); #ini_set('display_errors', 1); -umask(0); /* PHP version validation */ if (version_compare(phpversion(), '5.5.0', '<') === true) { diff --git a/app/code/Magento/Backup/Model/Fs/Collection.php b/app/code/Magento/Backup/Model/Fs/Collection.php index ffe89eeb6dd..888a072a57d 100644 --- a/app/code/Magento/Backup/Model/Fs/Collection.php +++ b/app/code/Magento/Backup/Model/Fs/Collection.php @@ -91,7 +91,6 @@ class Collection extends \Magento\Framework\Data\Collection\Filesystem $filename = '.htaccess'; if (!$this->_varDirectory->isFile($filename)) { $this->_varDirectory->writeFile($filename, 'deny from all'); - $this->_varDirectory->changePermissions($filename, 0640); } } diff --git a/app/code/Magento/Captcha/Helper/Data.php b/app/code/Magento/Captcha/Helper/Data.php index 05d33045eaa..8892ddc1ed3 100644 --- a/app/code/Magento/Captcha/Helper/Data.php +++ b/app/code/Magento/Captcha/Helper/Data.php @@ -150,8 +150,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper $mediaDir = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA); $captchaDir = '/captcha/' . $this->_getWebsiteCode($website); $mediaDir->create($captchaDir); - $mediaDir->changePermissions($captchaDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); - return $mediaDir->getAbsolutePath($captchaDir) . '/'; } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php index f9545bc9c77..05efbfa1557 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php @@ -157,7 +157,6 @@ class Processor $this->mediaDirectory->copyFile($file, $destinationFile); $storageHelper->saveFile($this->mediaConfig->getTmpMediaShortUrl($fileName)); - $this->mediaDirectory->changePermissions($destinationFile, DriverInterface::WRITEABLE_FILE_MODE); } } catch (\Exception $e) { throw new LocalizedException(__('We couldn\'t move this file: %1.', $e->getMessage())); diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 0bc5d358c83..bef6d7a558d 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -20,11 +20,15 @@ class Filesystem { /** * File access permissions + * + * @deprecated */ const PERMISSIONS_FILE = 0640; /** * Directory access permissions + * + * @deprecated */ const PERMISSIONS_DIR = 0750; @@ -109,19 +113,10 @@ class Filesystem DirectoryList::TMP_MATERIALIZATION_DIR ] ); - $this->changePermissions( - [ - DirectoryList::STATIC_VIEW - ], - self::PERMISSIONS_DIR, - self::PERMISSIONS_DIR - ); - // Trigger static assets compilation and deployment $this->deployStaticContent($output); // Trigger code generation $this->compile($output); - $this->lockStaticResources(); } /** @@ -227,6 +222,8 @@ class Filesystem * @param int $dirPermissions * @param int $filePermissions * @return void + * + * @deprecated */ protected function changePermissions($directoryCodeList, $dirPermissions, $filePermissions) { @@ -245,6 +242,8 @@ class Filesystem * Chenge permissions on static resources * * @return void + * + * @deprecated */ public function lockStaticResources() { diff --git a/app/code/Magento/Deploy/Model/Mode.php b/app/code/Magento/Deploy/Model/Mode.php index bcfe9bce215..788fb897a88 100644 --- a/app/code/Magento/Deploy/Model/Mode.php +++ b/app/code/Magento/Deploy/Model/Mode.php @@ -92,7 +92,6 @@ class Mode */ public function enableProductionModeMinimal() { - $this->filesystem->lockStaticResources(); $this->setStoreMode(State::MODE_PRODUCTION); } diff --git a/app/code/Magento/Translation/Model/FileManager.php b/app/code/Magento/Translation/Model/FileManager.php index d15a8ffbb53..b937a51baee 100644 --- a/app/code/Magento/Translation/Model/FileManager.php +++ b/app/code/Magento/Translation/Model/FileManager.php @@ -100,10 +100,7 @@ class FileManager \DIRECTORY_SEPARATOR . $this->assetRepo->getStaticViewFileContext()->getPath(); if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) { - $this->driverFile->createDirectory( - $translationDir, - \Magento\Framework\Filesystem\Driver\File::WRITEABLE_DIRECTORY_MODE - ); + $this->driverFile->createDirectory($translationDir); } $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content); } diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php index 6cb159e9c97..5d2a9d9f478 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php @@ -105,7 +105,7 @@ abstract class AbstractFactory * @return bool * @throws \Exception */ - protected function checkAndCreateFolder($folder, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE) + protected function checkAndCreateFolder($folder, $mode = 0777) { if (is_dir($folder)) { return true; @@ -127,7 +127,7 @@ abstract class AbstractFactory * @param bool $recursive * @return bool */ - protected function mkDir($dir, $mode = 0770, $recursive = true) + protected function mkDir($dir, $mode = 0777, $recursive = true) { return @mkdir($dir, $mode, $recursive); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 0a0676054bf..ef6b3e24da8 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -577,7 +577,7 @@ class Application { if (!file_exists($dir)) { $old = umask(0); - mkdir($dir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + mkdir($dir); umask($old); } elseif (!is_dir($dir)) { throw new \Magento\Framework\Exception\LocalizedException(__("'%1' is not a directory.", $dir)); diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php index e367ed3441d..a3baf43c549 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -25,7 +25,7 @@ class StorageTest extends \PHPUnit_Framework_TestCase 'Magento\Cms\Helper\Wysiwyg\Images' )->getCurrentPath() . 'MagentoCmsModelWysiwygImagesStorageTest'; if (!file_exists(self::$_baseDir)) { - mkdir(self::$_baseDir, 0770); + mkdir(self::$_baseDir); } touch(self::$_baseDir . '/1.swf'); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/WriteTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/WriteTest.php index 03f627d480f..ea3348b51ce 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/WriteTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Directory/WriteTest.php @@ -28,7 +28,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testInstance() { - $dir = $this->getDirectoryInstance('newDir1', 0770); + $dir = $this->getDirectoryInstance('newDir1', 0777); $this->assertTrue($dir instanceof ReadInterface); $this->assertTrue($dir instanceof WriteInterface); } @@ -56,10 +56,10 @@ class WriteTest extends \PHPUnit_Framework_TestCase public function createProvider() { return [ - ['newDir1', 0770, "newDir1"], - ['newDir1', 0770, "root_dir1/subdir1/subdir2"], - ['newDir2', 0750, "root_dir2/subdir"], - ['newDir1', 0770, "."] + ['newDir1', 0777, "newDir1"], + ['newDir1', 0777, "root_dir1/subdir1/subdir2"], + ['newDir2', 0777, "root_dir2/subdir"], + ['newDir1', 0777, "."] ]; } @@ -71,7 +71,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testDelete($path) { - $directory = $this->getDirectoryInstance('newDir', 0770); + $directory = $this->getDirectoryInstance('newDir', 0777); $directory->create($path); $this->assertTrue($directory->isExist($path)); $directory->delete($path); @@ -116,7 +116,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function renameProvider() { - return [['newDir1', 0770, 'first_name.txt', 'second_name.txt']]; + return [['newDir1', 0777, 'first_name.txt', 'second_name.txt']]; } /** @@ -150,7 +150,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function renameTargetDirProvider() { - return [['dir1', 'dir2', 0770, 'first_name.txt', 'second_name.txt']]; + return [['dir1', 'dir2', 0777, 'first_name.txt', 'second_name.txt']]; } /** @@ -180,8 +180,8 @@ class WriteTest extends \PHPUnit_Framework_TestCase public function copyProvider() { return [ - ['newDir1', 0770, 'first_name.txt', 'second_name.txt'], - ['newDir1', 0770, 'subdir/first_name.txt', 'subdir/second_name.txt'] + ['newDir1', 0777, 'first_name.txt', 'second_name.txt'], + ['newDir1', 0777, 'subdir/first_name.txt', 'subdir/second_name.txt'] ]; } @@ -216,8 +216,8 @@ class WriteTest extends \PHPUnit_Framework_TestCase public function copyTargetDirProvider() { return [ - ['dir1', 'dir2', 0770, 'first_name.txt', 'second_name.txt'], - ['dir1', 'dir2', 0770, 'subdir/first_name.txt', 'subdir/second_name.txt'] + ['dir1', 'dir2', 0777, 'first_name.txt', 'second_name.txt'], + ['dir1', 'dir2', 0777, 'subdir/first_name.txt', 'subdir/second_name.txt'] ]; } @@ -226,9 +226,9 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testChangePermissions() { - $directory = $this->getDirectoryInstance('newDir1', 0770); + $directory = $this->getDirectoryInstance('newDir1', 0777); $directory->create('test_directory'); - $this->assertTrue($directory->changePermissions('test_directory', 0640)); + $this->assertTrue($directory->changePermissions('test_directory', 0644)); } /** @@ -241,7 +241,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase $directory->create('test_directory/subdirectory'); $directory->writeFile('test_directory/subdirectory/test_file.txt', 'Test Content'); - $this->assertTrue($directory->changePermissionsRecursively('test_directory', 0750, 0640)); + $this->assertTrue($directory->changePermissionsRecursively('test_directory', 0777, 0644)); } /** @@ -269,8 +269,8 @@ class WriteTest extends \PHPUnit_Framework_TestCase public function touchProvider() { return [ - ['test_directory', 0770, 'touch_file.txt', time() - 3600], - ['test_directory', 0770, 'subdirectory/touch_file.txt', time() - 3600] + ['test_directory', 0777, 'touch_file.txt', time() - 3600], + ['test_directory', 0777, 'subdirectory/touch_file.txt', time() - 3600] ]; } @@ -279,7 +279,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testIsWritable() { - $directory = $this->getDirectoryInstance('newDir1', 0770); + $directory = $this->getDirectoryInstance('newDir1', 0777); $directory->create('bar'); $this->assertFalse($directory->isWritable('not_existing_dir')); $this->assertTrue($directory->isWritable('bar')); @@ -310,8 +310,8 @@ class WriteTest extends \PHPUnit_Framework_TestCase public function openFileProvider() { return [ - ['newDir1', 0770, 'newFile.txt', 'w+'], - ['newDir1', 0770, 'subdirectory/newFile.txt', 'w+'] + ['newDir1', 0777, 'newFile.txt', 'w+'], + ['newDir1', 0777, 'subdirectory/newFile.txt', 'w+'] ]; } @@ -325,7 +325,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testWriteFile($path, $content, $extraContent) { - $directory = $this->getDirectoryInstance('writeFileDir', 0770); + $directory = $this->getDirectoryInstance('writeFileDir', 0777); $directory->writeFile($path, $content); $this->assertEquals($content, $directory->readFile($path)); $directory->writeFile($path, $extraContent); @@ -342,7 +342,7 @@ class WriteTest extends \PHPUnit_Framework_TestCase */ public function testWriteFileAppend($path, $content, $extraContent) { - $directory = $this->getDirectoryInstance('writeFileDir', 0770); + $directory = $this->getDirectoryInstance('writeFileDir', 0777); $directory->writeFile($path, $content, 'a+'); $this->assertEquals($content, $directory->readFile($path)); $directory->writeFile($path, $extraContent, 'a+'); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php index 076a4aaca13..d060134274d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Filesystem/Driver/FileTest.php @@ -77,7 +77,7 @@ class FileTest extends \PHPUnit_Framework_TestCase if (is_dir($generatedPath)) { $this->assertTrue($this->driver->deleteDirectory($generatedPathBase)); } - $this->assertTrue($this->driver->createDirectory($generatedPath, DriverInterface::WRITEABLE_DIRECTORY_MODE)); + $this->assertTrue($this->driver->createDirectory($generatedPath)); $this->assertTrue(is_dir($generatedPath)); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index e4883336aa4..9477def83d2 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -70,15 +70,14 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $basePath = BP; $basePath = str_replace('\\', '/', $basePath); - $this->_tmpDir = realpath(__DIR__) . '/tmp'; $this->_generationDir = $this->_tmpDir . '/generation'; if (!file_exists($this->_generationDir)) { - mkdir($this->_generationDir, 0770, true); + mkdir($this->_generationDir, 0777, true); } $this->_compilationDir = $this->_tmpDir . '/di'; if (!file_exists($this->_compilationDir)) { - mkdir($this->_compilationDir, 0770, true); + mkdir($this->_compilationDir, 0777, true); } $this->_command = 'php ' . $basePath . '/bin/magento setup:di:compile-multi-tenant --generation=%s --di=%s'; diff --git a/dev/tests/static/testsuite/Magento/Test/Js/Exemplar/JsHintTest.php b/dev/tests/static/testsuite/Magento/Test/Js/Exemplar/JsHintTest.php index 41f50f98516..64cdf4906e2 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/Exemplar/JsHintTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Js/Exemplar/JsHintTest.php @@ -29,7 +29,7 @@ class JsHintTest extends \PHPUnit_Framework_TestCase { $reportFile = self::$_cmd->getReportFile(); if (!is_dir(dirname($reportFile))) { - mkdir(dirname($reportFile), 0770); + mkdir(dirname($reportFile)); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php index e0de4179198..955e39d3ea8 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php @@ -60,7 +60,7 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase { $reportDir = BP . '/dev/tests/static/report'; if (!is_dir($reportDir)) { - mkdir($reportDir, 0770); + mkdir($reportDir); } self::$_reportFile = $reportDir . '/js_report.txt'; @unlink(self::$_reportFile); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index a3ac3034df2..b0d448a7165 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -42,7 +42,7 @@ class LiveCodeTest extends PHPUnit_Framework_TestCase self::$pathToSource = BP; self::$reportDir = self::$pathToSource . '/dev/tests/static/report'; if (!is_dir(self::$reportDir)) { - mkdir(self::$reportDir, 0770); + mkdir(self::$reportDir); } } diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php index 169b350161d..c904a049e68 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php @@ -20,6 +20,7 @@ class Factory * Default cache entry lifetime */ const DEFAULT_LIFETIME = 7200; + /** * Caching params, that applied for all cache frontends regardless of type */ @@ -67,7 +68,7 @@ class Factory */ protected $_backendOptions = [ 'hashed_directory_level' => 1, - 'hashed_directory_umask' => DriverInterface::WRITEABLE_DIRECTORY_MODE, + 'hashed_directory_umask' => 0777, 'file_name_prefix' => 'mage', ]; diff --git a/lib/internal/Magento/Framework/Archive/Helper/File.php b/lib/internal/Magento/Framework/Archive/Helper/File.php index 4a72a2846a7..a0e8b3084e8 100644 --- a/lib/internal/Magento/Framework/Archive/Helper/File.php +++ b/lib/internal/Magento/Framework/Archive/Helper/File.php @@ -91,7 +91,7 @@ class File * @throws LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function open($mode = 'w+', $chmod = DriverInterface::WRITEABLE_FILE_MODE) + public function open($mode = 'w+', $chmod = null) { $this->_isInWriteMode = $this->_isWritableMode($mode); @@ -182,7 +182,7 @@ class File $this->_close(); $this->_fileHandler = false; - if ($this->_isInWriteMode) { + if ($this->_isInWriteMode && isset($this->_chmod)) { @chmod($this->_filePath, $this->_chmod); } } diff --git a/lib/internal/Magento/Framework/Archive/Tar.php b/lib/internal/Magento/Framework/Archive/Tar.php index d02fc9e24cb..fc57ef13402 100644 --- a/lib/internal/Magento/Framework/Archive/Tar.php +++ b/lib/internal/Magento/Framework/Archive/Tar.php @@ -404,7 +404,7 @@ class Tar extends \Magento\Framework\Archive\AbstractArchive implements \Magento if (in_array($header['type'], ["0", chr(0), ''])) { if (!file_exists($dirname)) { - $mkdirResult = @mkdir($dirname, DriverInterface::WRITEABLE_DIRECTORY_MODE, true); + $mkdirResult = @mkdir($dirname, 0777, true); if (false === $mkdirResult) { throw new \Magento\Framework\Exception\LocalizedException( diff --git a/lib/internal/Magento/Framework/Backup/Filesystem.php b/lib/internal/Magento/Framework/Backup/Filesystem.php index 4577bdda32e..ce1aa07ea37 100644 --- a/lib/internal/Magento/Framework/Backup/Filesystem.php +++ b/lib/internal/Magento/Framework/Backup/Filesystem.php @@ -279,7 +279,7 @@ class Filesystem extends AbstractBackup } mkdir($backupsDir); - chmod($backupsDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + chmod($backupsDir); } if (!is_writable($backupsDir)) { diff --git a/lib/internal/Magento/Framework/Backup/Filesystem/Rollback/Ftp.php b/lib/internal/Magento/Framework/Backup/Filesystem/Rollback/Ftp.php index 44ec96f4dca..11c689884cb 100644 --- a/lib/internal/Magento/Framework/Backup/Filesystem/Rollback/Ftp.php +++ b/lib/internal/Magento/Framework/Backup/Filesystem/Rollback/Ftp.php @@ -126,7 +126,7 @@ class Ftp extends AbstractRollback { $tmpDir = $this->_snapshot->getBackupsDir() . '/~tmp-' . microtime(true); - $result = @mkdir($tmpDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + $result = @mkdir($tmpDir); if (false === $result) { throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions( diff --git a/lib/internal/Magento/Framework/Code/Generator/Io.php b/lib/internal/Magento/Framework/Code/Generator/Io.php index 4bdd3851eeb..aac1eea8d6c 100644 --- a/lib/internal/Magento/Framework/Code/Generator/Io.php +++ b/lib/internal/Magento/Framework/Code/Generator/Io.php @@ -169,7 +169,7 @@ class Io } try { if (!$this->filesystemDriver->isDirectory($directory)) { - $this->filesystemDriver->createDirectory($directory, DriverInterface::WRITEABLE_DIRECTORY_MODE); + $this->filesystemDriver->createDirectory($directory); } return true; } catch (FileSystemException $e) { diff --git a/lib/internal/Magento/Framework/File/Uploader.php b/lib/internal/Magento/Framework/File/Uploader.php index 573b2efdd4d..14077be8aeb 100644 --- a/lib/internal/Magento/Framework/File/Uploader.php +++ b/lib/internal/Magento/Framework/File/Uploader.php @@ -223,7 +223,6 @@ class Uploader $this->_result = $this->_moveFile($this->_file['tmp_name'], $destinationFile); if ($this->_result) { - $this->chmod($destinationFile); if ($this->_enableFilesDispersion) { $fileName = str_replace('\\', '/', self::_addDirSeparator($this->_dispretionPath)) . $fileName; } @@ -242,10 +241,12 @@ class Uploader /** * @param string $file * @return void + * + * @deprecated */ protected function chmod($file) { - chmod($file, DriverInterface::WRITEABLE_DIRECTORY_MODE); + chmod($file, 0777); } /** @@ -554,7 +555,7 @@ class Uploader } if (!(@is_dir($destinationFolder) - || @mkdir($destinationFolder, DriverInterface::WRITEABLE_DIRECTORY_MODE, true) + || @mkdir($destinationFolder, 0777, true) )) { throw new \Exception("Unable to create directory '{$destinationFolder}'."); } diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php index 22ffa68bd70..0a46a17c10b 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php @@ -15,7 +15,7 @@ class Write extends Read implements WriteInterface * * @var int */ - protected $permissions = DriverInterface::WRITEABLE_DIRECTORY_MODE; + protected $permissions = 0777; /** * Constructor diff --git a/lib/internal/Magento/Framework/Filesystem/Driver/File.php b/lib/internal/Magento/Framework/Filesystem/Driver/File.php index a0b9afcd2ca..8f7d888544f 100644 --- a/lib/internal/Magento/Framework/Filesystem/Driver/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Driver/File.php @@ -194,7 +194,7 @@ class File implements DriverInterface * @return bool * @throws FileSystemException */ - public function createDirectory($path, $permissions) + public function createDirectory($path, $permissions = 0777) { return $this->mkdirRecursive($path, $permissions); } @@ -207,7 +207,7 @@ class File implements DriverInterface * @return bool * @throws FileSystemException */ - private function mkdirRecursive($path, $permissions) + private function mkdirRecursive($path, $permissions = 0777) { $path = $this->getScheme() . $path; if (is_dir($path)) { diff --git a/lib/internal/Magento/Framework/Filesystem/DriverInterface.php b/lib/internal/Magento/Framework/Filesystem/DriverInterface.php index 2d1748afb15..5e297b237e2 100644 --- a/lib/internal/Magento/Framework/Filesystem/DriverInterface.php +++ b/lib/internal/Magento/Framework/Filesystem/DriverInterface.php @@ -16,11 +16,15 @@ interface DriverInterface { /** * Permissions to give read/write/execute access to owner and owning group, but not to all users + * + * @deprecated */ const WRITEABLE_DIRECTORY_MODE = 0770; /** * Permissions to give read/write access to owner and owning group, but not to all users + * + * @deprecated */ const WRITEABLE_FILE_MODE = 0660; @@ -104,7 +108,7 @@ interface DriverInterface * @return bool * @throws FileSystemException */ - public function createDirectory($path, $permissions); + public function createDirectory($path, $permissions = 0777); /** * Read directory diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php index 65c92dfd37e..a835c4b25fe 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php @@ -301,7 +301,7 @@ class File extends AbstractIo * @param bool $recursive * @return bool */ - public function mkdir($dir, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE, $recursive = true) + public function mkdir($dir, $mode = 0777, $recursive = true) { $this->_cwd(); $result = @mkdir($dir, $mode, $recursive); @@ -553,7 +553,7 @@ class File extends AbstractIo * @return true * @throws \Exception */ - public function checkAndCreateFolder($folder, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE) + public function checkAndCreateFolder($folder, $mode = 0777) { if (is_dir($folder)) { return true; diff --git a/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php b/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php index 85d4c5fcd76..eb14a261b48 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php @@ -159,7 +159,7 @@ class Ftp extends AbstractIo * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function mkdir($dir, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE, $recursive = true) + public function mkdir($dir, $mode = 0777, $recursive = true) { return @ftp_mkdir($this->_conn, $dir); } diff --git a/lib/internal/Magento/Framework/Filesystem/Io/IoInterface.php b/lib/internal/Magento/Framework/Filesystem/Io/IoInterface.php index b3b01736e2b..1adba174ede 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/IoInterface.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/IoInterface.php @@ -35,7 +35,7 @@ interface IoInterface * @param bool $recursive * @return bool */ - public function mkdir($dir, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE, $recursive = true); + public function mkdir($dir, $mode = 0777, $recursive = true); /** * Delete a directory diff --git a/lib/internal/Magento/Framework/Filesystem/Io/Sftp.php b/lib/internal/Magento/Framework/Filesystem/Io/Sftp.php index db5ae3af625..f6554426914 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/Sftp.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/Sftp.php @@ -78,7 +78,7 @@ class Sftp extends AbstractIo * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function mkdir($dir, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE, $recursive = true) + public function mkdir($dir, $mode = 0777, $recursive = true) { if ($recursive) { $no_errors = true; diff --git a/lib/internal/Magento/Framework/Logger/Handler/Base.php b/lib/internal/Magento/Framework/Logger/Handler/Base.php index 36a8cbb4a09..21c71ef4d64 100644 --- a/lib/internal/Magento/Framework/Logger/Handler/Base.php +++ b/lib/internal/Magento/Framework/Logger/Handler/Base.php @@ -54,7 +54,7 @@ class Base extends StreamHandler { $logDir = $this->filesystem->getParentDirectory($this->url); if (!$this->filesystem->isDirectory($logDir)) { - $this->filesystem->createDirectory($logDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + $this->filesystem->createDirectory($logDir); } parent::write($record); diff --git a/lib/internal/Magento/Framework/Setup/BackupRollback.php b/lib/internal/Magento/Framework/Setup/BackupRollback.php index 7bc6ae974d2..abc65749853 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollback.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollback.php @@ -121,7 +121,7 @@ class BackupRollback throw new LocalizedException(new Phrase("This backup type \'$type\' is not supported.")); } if (!$this->file->isExists($this->backupsDir)) { - $this->file->createDirectory($this->backupsDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + $this->file->createDirectory($this->backupsDir); } $fsBackup->setBackupsDir($this->backupsDir); $fsBackup->setBackupExtension('tgz'); @@ -201,7 +201,7 @@ class BackupRollback $dbBackup = $this->objectManager->create('Magento\Framework\Backup\Db'); $dbBackup->setRootDir($this->directoryList->getRoot()); if (!$this->file->isExists($this->backupsDir)) { - $this->file->createDirectory($this->backupsDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); + $this->file->createDirectory($this->backupsDir); } $dbBackup->setBackupsDir($this->backupsDir); $dbBackup->setBackupExtension('sql'); diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php index 349b722d135..f8fa352fbbb 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php @@ -107,7 +107,7 @@ class BackupRollbackTest extends \PHPUnit_Framework_TestCase $this->filesystem->expects($this->once()) ->method('create'); $this->file->expects($this->once())->method('isExists')->with($this->path . '/backups')->willReturn(false); - $this->file->expects($this->once())->method('createDirectory')->with($this->path . '/backups', 0770); + $this->file->expects($this->once())->method('createDirectory')->with($this->path . '/backups', 0777); $this->model->codeBackup(time()); } @@ -158,7 +158,7 @@ class BackupRollbackTest extends \PHPUnit_Framework_TestCase $this->filesystem->expects($this->once()) ->method('create'); $this->file->expects($this->once())->method('isExists')->with($this->path . '/backups')->willReturn(false); - $this->file->expects($this->once())->method('createDirectory')->with($this->path . '/backups', 0770); + $this->file->expects($this->once())->method('createDirectory')->with($this->path . '/backups', 0777); $this->model->codeBackup(time(), Factory::TYPE_MEDIA); } diff --git a/lib/internal/Magento/Framework/System/Dirs.php b/lib/internal/Magento/Framework/System/Dirs.php index 0e16ddfbf11..5e3e9040ef7 100644 --- a/lib/internal/Magento/Framework/System/Dirs.php +++ b/lib/internal/Magento/Framework/System/Dirs.php @@ -75,7 +75,7 @@ class Dirs * @return true * @throws \Exception */ - public static function mkdirStrict($path, $recursive = true, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE) + public static function mkdirStrict($path, $recursive = true, $mode = 0777) { $exists = file_exists($path); if ($exists && is_dir($path)) { diff --git a/lib/internal/Magento/Framework/System/Ftp.php b/lib/internal/Magento/Framework/System/Ftp.php index 932afef19e3..564f4473eae 100644 --- a/lib/internal/Magento/Framework/System/Ftp.php +++ b/lib/internal/Magento/Framework/System/Ftp.php @@ -52,7 +52,7 @@ class Ftp * @param int $mode * @return bool */ - public function mkdirRecursive($path, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE) + public function mkdirRecursive($path, $mode = 0777) { $this->checkConnected(); $dir = explode("/", $path); @@ -219,7 +219,7 @@ class Ftp * @return bool * @throws \Exception */ - public function upload($remote, $local, $dirMode = DriverInterface::WRITEABLE_DIRECTORY_MODE, $ftpMode = FTP_BINARY) + public function upload($remote, $local, $dirMode = 0777, $ftpMode = FTP_BINARY) { $this->checkConnected(); diff --git a/pub/errors/processor.php b/pub/errors/processor.php index 78f1ccc16f7..f5415d14ab5 100644 --- a/pub/errors/processor.php +++ b/pub/errors/processor.php @@ -454,11 +454,10 @@ class Processor $this->_setReportData($reportData); if (!file_exists($this->_reportDir)) { - @mkdir($this->_reportDir, DriverInterface::WRITEABLE_DIRECTORY_MODE, true); + @mkdir($this->_reportDir, 0777, true); } @file_put_contents($this->_reportFile, serialize($reportData)); - @chmod($this->_reportFile, DriverInterface::WRITEABLE_FILE_MODE); if (isset($reportData['skin']) && self::DEFAULT_SKIN != $reportData['skin']) { $this->_setSkin($reportData['skin']); diff --git a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php index dda46f47fc3..7ecc51c8ead 100644 --- a/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php +++ b/setup/src/Magento/Setup/Console/Command/DiCompileMultiTenantCommand.php @@ -395,7 +395,7 @@ class DiCompileMultiTenantCommand extends AbstractSetupCommand // 2.2 Compression $relationsFileDir = dirname($relationsFile); if (!file_exists($relationsFileDir)) { - mkdir($relationsFileDir, DriverInterface::WRITEABLE_DIRECTORY_MODE, true); + mkdir($relationsFileDir, 0777, true); } $relations = array_filter($relations); file_put_contents($relationsFile, $serializer->serialize($relations)); @@ -413,7 +413,7 @@ class DiCompileMultiTenantCommand extends AbstractSetupCommand $outputContent = $serializer->serialize($pluginDefinitions); $pluginDefFileDir = dirname($pluginDefFile); if (!file_exists($pluginDefFileDir)) { - mkdir($pluginDefFileDir, DriverInterface::WRITEABLE_DIRECTORY_MODE, true); + mkdir($pluginDefFileDir, 0777, true); } file_put_contents($pluginDefFile, $outputContent); } diff --git a/setup/src/Magento/Setup/Model/MarketplaceManager.php b/setup/src/Magento/Setup/Model/MarketplaceManager.php index 895623530bb..c72e7892297 100644 --- a/setup/src/Magento/Setup/Model/MarketplaceManager.php +++ b/setup/src/Magento/Setup/Model/MarketplaceManager.php @@ -309,10 +309,6 @@ class MarketplaceManager \Magento\Framework\App\Filesystem\DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile, $jsonContent - ) && $this->getDirectory()->changePermissions( - \Magento\Framework\App\Filesystem\DirectoryList::COMPOSER_HOME . - DIRECTORY_SEPARATOR . $this->pathToAuthFile, - \Magento\Framework\Filesystem\DriverInterface::WRITEABLE_FILE_MODE ); } diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php index ab8780a8045..daf8425802a 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php @@ -51,7 +51,7 @@ class Filesystem implements WriterInterface private function initialize() { if (!file_exists($this->directoryList->getPath(DirectoryList::DI))) { - mkdir($this->directoryList->getPath(DirectoryList::DI), DriverInterface::WRITEABLE_DIRECTORY_MODE); + mkdir($this->directoryList->getPath(DirectoryList::DI)); } } } diff --git a/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php b/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php index 9f838c7cd2c..00a1361c3c7 100644 --- a/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php +++ b/setup/src/Magento/Setup/Module/I18n/Pack/Writer/File/AbstractFile.php @@ -143,7 +143,7 @@ abstract class AbstractFile implements WriterInterface * @param bool $recursive Allows the creation of nested directories specified in the $destinationPath * @return void */ - protected function _createDirectoryIfNotExist($destinationPath, $mode = 0750, $recursive = true) + protected function _createDirectoryIfNotExist($destinationPath, $mode = 0777, $recursive = true) { if (!is_dir($destinationPath)) { mkdir($destinationPath, $mode, $recursive); -- GitLab