MDL-22546 improving dir creation handling and improving dataroot support in config only scripts; using 02777 as default in lib/setup.php to match the default in config-dist.php

This commit is contained in:
Petr Skoda 2010-05-22 19:59:59 +00:00
parent 173ba4f1ca
commit 4cee2155b2
2 changed files with 12 additions and 11 deletions

View file

@ -9239,8 +9239,9 @@ function remove_dir($dir, $content_only=false) {
function check_dir_exists($dir, $create=false, $recursive=false) { function check_dir_exists($dir, $create=false, $recursive=false) {
global $CFG; global $CFG;
if (strstr(cleardoubleslashes($dir), cleardoubleslashes($CFG->dataroot.'/')) === false) { if (strpos(str_replace('\\', '/', $dir), str_replace('\\', '/', $CFG->dataroot.'/')) !== 0) {
debugging('Warning. Wrong call to check_dir_exists(). $dir must be an absolute path under $CFG->dataroot ("' . $dir . '" is incorrect)', DEBUG_DEVELOPER); debugging('Warning. Wrong call to check_dir_exists(). $dir must be an absolute path under $CFG->dataroot ("' . $dir . '" is incorrect)', DEBUG_DEVELOPER);
return false;
} }
$status = true; $status = true;

View file

@ -108,6 +108,16 @@ if (!defined('AJAX_SCRIPT')) {
define('AJAX_SCRIPT', false); define('AJAX_SCRIPT', false);
} }
// File permissions on created directories in the $CFG->dataroot
if (empty($CFG->directorypermissions)) {
$CFG->directorypermissions = 02777; // Must be octal (that's why it's here)
}
if (empty($CFG->filepermissions)) {
$CFG->filepermissions = ($CFG->directorypermissions & 0666); // strip execute flags
}
// better also set default umask because recursive mkdir() does not apply permissions recursively otherwise
umask(0000);
// exact version of currently used yui2 and 3 library // exact version of currently used yui2 and 3 library
$CFG->yui2version = '2.8.1'; $CFG->yui2version = '2.8.1';
$CFG->yui3version = '3.1.1'; $CFG->yui3version = '3.1.1';
@ -476,16 +486,6 @@ if (!empty($CFG->cachetype)) {
$CFG->rcache = false; $CFG->rcache = false;
} }
// File permissions on created directories in the $CFG->dataroot
if (empty($CFG->directorypermissions)) {
$CFG->directorypermissions = 0777; // Must be octal (that's why it's here)
}
if (empty($CFG->filepermissions)) {
$CFG->filepermissions = ($CFG->directorypermissions & 0666); // strip execute flags
}
// better also set default umask because recursive mkdir() does not apply permissions recursively otherwise
umask(0000);
// Calculate and set $CFG->ostype to be used everywhere. Possible values are: // Calculate and set $CFG->ostype to be used everywhere. Possible values are:
// - WINDOWS: for any Windows flavour. // - WINDOWS: for any Windows flavour.
// - UNIX: for the rest // - UNIX: for the rest