mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-04 03:40:53 +02:00
Change file permissions for directories and respect umask for written files. (#828)
Fixes #548 Fixes #819
This commit is contained in:
@@ -29,7 +29,6 @@ class Smarty_Internal_Runtime_WriteFile
|
||||
{
|
||||
$_error_reporting = error_reporting();
|
||||
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
|
||||
$old_umask = umask(0);
|
||||
$_dirpath = dirname($_filepath);
|
||||
// if subdirs, create dir structure
|
||||
if ($_dirpath !== '.') {
|
||||
@@ -37,7 +36,7 @@ class Smarty_Internal_Runtime_WriteFile
|
||||
// loop if concurrency problem occurs
|
||||
// see https://bugs.php.net/bug.php?id=35326
|
||||
while (!is_dir($_dirpath)) {
|
||||
if (@mkdir($_dirpath, 0771, true)) {
|
||||
if (@mkdir($_dirpath, 0777, true)) {
|
||||
break;
|
||||
}
|
||||
clearstatcache();
|
||||
@@ -85,8 +84,7 @@ class Smarty_Internal_Runtime_WriteFile
|
||||
throw new SmartyException("unable to write file {$_filepath}");
|
||||
}
|
||||
// set file permissions
|
||||
chmod($_filepath, 0644);
|
||||
umask($old_umask);
|
||||
@chmod($_filepath, 0666 & ~umask());
|
||||
error_reporting($_error_reporting);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user