mirror of
https://github.com/moodle/moodle.git
synced 2025-03-04 16:10:59 +01:00
Merge branch 'w29_MDL-40435_m26_componentpermissions' of https://github.com/skodak/moodle
This commit is contained in:
commit
c49fea3be5
@ -22,6 +22,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Collection of components related methods.
|
||||
*/
|
||||
@ -155,16 +157,21 @@ class core_component {
|
||||
unlink($cachefile);
|
||||
}
|
||||
|
||||
// Permissions might not be setup properly in installers.
|
||||
$dirpermissions = !isset($CFG->directorypermissions) ? 02777 : $CFG->directorypermissions;
|
||||
$filepermissions = !isset($CFG->filepermissions) ? ($dirpermissions & 0666) : $CFG->filepermissions;
|
||||
|
||||
clearstatcache();
|
||||
$cachedir = dirname($cachefile);
|
||||
if (!is_dir($cachedir)) {
|
||||
mkdir($cachedir, $CFG->directorypermissions, true);
|
||||
mkdir($cachedir, $dirpermissions, true);
|
||||
}
|
||||
|
||||
if ($fp = @fopen($cachefile.'.tmp', 'xb')) {
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
@rename($cachefile.'.tmp', $cachefile);
|
||||
@chmod($cachefile, $CFG->filepermissions);
|
||||
@chmod($cachefile, $filepermissions);
|
||||
}
|
||||
@unlink($cachefile.'.tmp'); // Just in case anything fails (race condition).
|
||||
self::invalidate_opcode_php_cache($cachefile);
|
||||
|
@ -276,10 +276,10 @@ if (!defined('AJAX_SCRIPT')) {
|
||||
}
|
||||
|
||||
// File permissions on created directories in the $CFG->dataroot
|
||||
if (empty($CFG->directorypermissions)) {
|
||||
if (!isset($CFG->directorypermissions)) {
|
||||
$CFG->directorypermissions = 02777; // Must be octal (that's why it's here)
|
||||
}
|
||||
if (empty($CFG->filepermissions)) {
|
||||
if (!isset($CFG->filepermissions)) {
|
||||
$CFG->filepermissions = ($CFG->directorypermissions & 0666); // strip execute flags
|
||||
}
|
||||
// better also set default umask because recursive mkdir() does not apply permissions recursively otherwise
|
||||
|
Loading…
x
Reference in New Issue
Block a user