Skip to content
Snippets Groups Projects
Commit fea6131e authored by totten's avatar totten
Browse files

More consistently restrict access to template, config/log, and upload dirs.

parent e7d3e318
Branches
Tags
No related merge requests found
......@@ -335,6 +335,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
CRM_Utils_File::baseFilePath($this->templateCompileDir) .
'ConfigAndLog' . DIRECTORY_SEPARATOR;
CRM_Utils_File::createDir($this->configAndLogDir);
CRM_Utils_File::restrictAccess($this->configAndLogDir);
// we're automatically prefixing compiled templates directories with country/language code
global $tsLocale;
......@@ -346,6 +347,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
}
CRM_Utils_File::createDir($this->templateCompileDir);
CRM_Utils_File::restrictAccess($this->templateCompileDir);
}
elseif ($loadFromDB) {
echo 'You need to define CIVICRM_TEMPLATE_COMPILEDIR in civicrm.settings.php';
......@@ -466,6 +468,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
if (substr($this->templateCompileDir, -1 * strlen($value) - 1, -1) != $value) {
$this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value);
CRM_Utils_File::createDir($this->templateCompileDir);
CRM_Utils_File::restrictAccess($this->templateCompileDir);
}
}
......@@ -623,7 +626,14 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
// clean upload dir
CRM_Utils_File::cleanDir($this->uploadDir);
CRM_Utils_File::createDir($this->uploadDir);
CRM_Utils_File::restrictAccess($this->uploadDir);
}
// Whether we delete/create or simply preserve directories, we should
// certainly make sure the restrictions are enforced.
foreach (array($this->templateCompileDir, $this->uploadDir, $this->configAndLogDir) as $dir) {
if ($dir && is_dir($dir)) {
CRM_Utils_File::restrictAccess($dir);
}
}
}
......
......@@ -82,6 +82,11 @@ class CRM_Utils_Check_Security {
if (CRM_Core_Permission::check('administer CiviCRM')) {
$session = CRM_Core_Session::singleton();
if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) {
// Best attempt at re-securing folders
$config = CRM_Core_Config::singleton();
$config->cleanup(0, FALSE);
foreach ($this->checkAll() as $message) {
CRM_Core_Session::setStatus($message, ts('Security Warning'));
}
......@@ -138,7 +143,6 @@ class CRM_Utils_Check_Security {
$log = CRM_Core_Error::createDebugLogger();
$log_filename = $log->_filename;
$config = CRM_Core_Config::singleton();
$filePathMarker = $this->getFilePathMarker();
// Hazard a guess at the URL of the logfile, based on common
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment