From 4cee2155b2a16bfb1942b2499b91b5c3b6863763 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 22 May 2010 19:59:59 +0000 Subject: [PATCH] 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 --- lib/moodlelib.php | 3 ++- lib/setup.php | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 42a10e8ef18..d3c707033f2 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -9239,8 +9239,9 @@ function remove_dir($dir, $content_only=false) { function check_dir_exists($dir, $create=false, $recursive=false) { 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); + return false; } $status = true; diff --git a/lib/setup.php b/lib/setup.php index 07e9ca38b8a..d57484dbce9 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -108,6 +108,16 @@ if (!defined('AJAX_SCRIPT')) { 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 $CFG->yui2version = '2.8.1'; $CFG->yui3version = '3.1.1'; @@ -476,16 +486,6 @@ if (!empty($CFG->cachetype)) { $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: // - WINDOWS: for any Windows flavour. // - UNIX: for the rest