Skip to content

Commit 28caa4f

Browse files
MAGETWO-52322: port file permissions fixes to 2.0 branch
1 parent 5702983 commit 28caa4f

File tree

42 files changed

+99
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+99
-85
lines changed

.htaccess

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
# SetEnv MAGE_MODE developer
66

7+
############################################
8+
## overrides default umask value to allow using different
9+
## file permissions
10+
11+
# SetEnv MAGE_UMASK 022
12+
713
############################################
814
## uncomment these lines for CGI mode
915
## make sure to specify the correct cgi php binary file name

.htaccess.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
# SetEnv MAGE_MODE developer
55

6+
############################################
7+
## overrides default umask value to allow using different
8+
## file permissions
9+
10+
# SetEnv MAGE_UMASK 022
11+
612
############################################
713
## uncomment these lines for CGI mode
814
## make sure to specify the correct cgi php binary file name

app/bootstrap.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
*/
1010
error_reporting(E_ALL);
1111
#ini_set('display_errors', 1);
12-
umask(0);
12+
13+
/* Custom umask value may be provided in MAGE_UMASK environment variable */
14+
$mask = isset($_SERVER['MAGE_UMASK']) ? octdec($_SERVER['MAGE_UMASK']) : 002;
15+
umask($mask);
1316

1417
/* PHP version validation */
1518
if (version_compare(phpversion(), '5.5.0', '<') === true) {

app/code/Magento/Backup/Model/Fs/Collection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ protected function _hideBackupsForApache()
9191
$filename = '.htaccess';
9292
if (!$this->_varDirectory->isFile($filename)) {
9393
$this->_varDirectory->writeFile($filename, 'deny from all');
94-
$this->_varDirectory->changePermissions($filename, 0640);
9594
}
9695
}
9796

app/code/Magento/Captcha/Helper/Data.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ public function getImgDir($website = null)
150150
$mediaDir = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA);
151151
$captchaDir = '/captcha/' . $this->_getWebsiteCode($website);
152152
$mediaDir->create($captchaDir);
153-
$mediaDir->changePermissions($captchaDir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
154-
155153
return $mediaDir->getAbsolutePath($captchaDir) . '/';
156154
}
157155

app/code/Magento/Catalog/Model/Product/Attribute/Backend/AbstractMedia.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ public function addImage(
170170
$storageHelper->saveFile($this->mediaConfig->getTmpMediaShortUrl($fileName));
171171
} else {
172172
$this->mediaDirectory->copyFile($file, $destinationFile);
173-
174173
$storageHelper->saveFile($this->mediaConfig->getTmpMediaShortUrl($fileName));
175-
$this->mediaDirectory->changePermissions($destinationFile, DriverInterface::WRITEABLE_FILE_MODE);
176174
}
177175
} catch (\Exception $e) {
178176
throw new LocalizedException(__('We couldn\'t move this file: %1.', $e->getMessage()));

app/code/Magento/Deploy/Model/Filesystem.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ class Filesystem
1818
{
1919
/**
2020
* File access permissions
21+
*
22+
* @deprecated
2123
*/
2224
const PERMISSIONS_FILE = 0640;
2325

2426
/**
2527
* Directory access permissions
28+
*
29+
* @deprecated
2630
*/
2731
const PERMISSIONS_DIR = 0750;
2832

@@ -107,19 +111,11 @@ public function regenerateStatic(
107111
DirectoryList::TMP_MATERIALIZATION_DIR
108112
]
109113
);
110-
$this->changePermissions(
111-
[
112-
DirectoryList::STATIC_VIEW
113-
],
114-
self::PERMISSIONS_DIR,
115-
self::PERMISSIONS_DIR
116-
);
117114

118115
// Trigger static assets compilation and deployment
119116
$this->deployStaticContent($output);
120117
// Trigger code generation
121118
$this->compile($output);
122-
$this->lockStaticResources();
123119
}
124120

125121
/**
@@ -215,6 +211,8 @@ public function cleanupFilesystem($directoryCodeList)
215211
* @param int $dirPermissions
216212
* @param int $filePermissions
217213
* @return void
214+
*
215+
* @deprecated
218216
*/
219217
protected function changePermissions($directoryCodeList, $dirPermissions, $filePermissions)
220218
{
@@ -233,6 +231,8 @@ protected function changePermissions($directoryCodeList, $dirPermissions, $fileP
233231
* Chenge permissions on static resources
234232
*
235233
* @return void
234+
*
235+
* @deprecated
236236
*/
237237
public function lockStaticResources()
238238
{

app/code/Magento/Deploy/Model/Mode.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public function enableProductionMode()
9292
*/
9393
public function enableProductionModeMinimal()
9494
{
95-
$this->filesystem->lockStaticResources();
9695
$this->setStoreMode(State::MODE_PRODUCTION);
9796
}
9897

dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected function endFactory($type)
105105
* @return bool
106106
* @throws \Exception
107107
*/
108-
protected function checkAndCreateFolder($folder, $mode = DriverInterface::WRITEABLE_DIRECTORY_MODE)
108+
protected function checkAndCreateFolder($folder, $mode = 0777)
109109
{
110110
if (is_dir($folder)) {
111111
return true;
@@ -127,7 +127,7 @@ protected function checkAndCreateFolder($folder, $mode = DriverInterface::WRITEA
127127
* @param bool $recursive
128128
* @return bool
129129
*/
130-
protected function mkDir($dir, $mode = 0770, $recursive = true)
130+
protected function mkDir($dir, $mode = 0777, $recursive = true)
131131
{
132132
return @mkdir($dir, $mode, $recursive);
133133
}

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ protected function _ensureDirExists($dir)
573573
{
574574
if (!file_exists($dir)) {
575575
$old = umask(0);
576-
mkdir($dir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
576+
mkdir($dir);
577577
umask($old);
578578
} elseif (!is_dir($dir)) {
579579
throw new \Magento\Framework\Exception\LocalizedException(__("'%1' is not a directory.", $dir));

0 commit comments

Comments
 (0)