Skip to content

Commit

Permalink
MDL-35852 Add config option to prevent changes to configexecutable se…
Browse files Browse the repository at this point in the history
…ttings
  • Loading branch information
Hugh Davenport authored and danmarsden committed May 6, 2013
1 parent 95190fd commit 9a2b5e0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions config-dist.php
Expand Up @@ -456,6 +456,12 @@
// To ensure they are never used even when available:
// $CFG->svgicons = false;
//
// Some administration options allow setting the path to executable files. This can
// potentially cause a security risk. Set this option to true to disable editing
// those config settings via the web. They will need to be set explicitly in the
// config.php file
// $CFG->preventexecpath = true;
//
//=========================================================================
// 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!
//=========================================================================
Expand Down
1 change: 1 addition & 0 deletions lang/en/admin.php
Expand Up @@ -513,6 +513,7 @@
$string['errorwithsettings'] = 'Some settings were not changed due to an error.';
$string['everyonewhocan'] = 'Everyone who can \'{$a}\'';
$string['exceptions'] = 'exceptions';
$string['execpathnotallowed'] = 'Setting executable paths disabled in config.php';
$string['experimental'] = 'Experimental';
$string['experimentalsettings'] = 'Experimental settings';
$string['extendedusernamechars'] = 'Allow extended characters in usernames';
Expand Down
14 changes: 14 additions & 0 deletions lib/adminlib.php
Expand Up @@ -2107,6 +2107,16 @@ public function output_html($data, $query='') {
'<div class="form-file defaultsnext"><input type="text" size="'.$this->size.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
$this->description, true, '', $default, $query);
}
/**
* checks if execpatch has been disabled in config.php
*/
public function write_setting($data) {
global $CFG;
if (!empty($CFG->preventexecpath)) {
return '';
}
return parent::write_setting($data);
}
}


Expand All @@ -2125,6 +2135,7 @@ class admin_setting_configexecutable extends admin_setting_configfile {
* @return string XHTML field
*/
public function output_html($data, $query='') {
global $CFG;
$default = $this->get_defaultsetting();

if ($data) {
Expand All @@ -2136,6 +2147,9 @@ public function output_html($data, $query='') {
} else {
$executable = '';
}
if (!empty($CFG->preventexecpath)) {
$this->visiblename .= '<div class="form-overridden">'.get_string('execpathnotallowed', 'admin').'</div>';
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-file defaultsnext"><input type="text" size="'.$this->size.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'" value="'.s($data).'" />'.$executable.'</div>',
Expand Down

0 comments on commit 9a2b5e0

Please sign in to comment.