diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-03-27 16:32:51 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-03-27 16:42:03 +0100 |
commit | e6d376236ee5bfb36c4cf11719500d6bdedcc535 (patch) | |
tree | f3f37d45871afa134f6339391c6e1e7c927eba69 /program | |
parent | 8320af552c7e2701339cc0bae7e0b5d3292a4db4 (diff) |
Whitelist configuration options (user preferences) that can be changed using save-pref command
Diffstat (limited to 'program')
-rw-r--r-- | program/lib/Roundcube/rcube_plugin.php | 8 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_plugin_api.php | 6 | ||||
-rw-r--r-- | program/steps/utils/save_pref.inc | 16 |
3 files changed, 30 insertions, 0 deletions
diff --git a/program/lib/Roundcube/rcube_plugin.php b/program/lib/Roundcube/rcube_plugin.php index 66e77cce2..34720cfd7 100644 --- a/program/lib/Roundcube/rcube_plugin.php +++ b/program/lib/Roundcube/rcube_plugin.php @@ -60,6 +60,14 @@ abstract class rcube_plugin */ public $noframe = false; + /** + * A list of config option names that can be modified + * by the user via user interface (with save-prefs command) + * + * @var array + */ + public $allowed_prefs; + protected $home; protected $urlbase; private $mytask; diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php index 8a4cce215..d2fa1c55d 100644 --- a/program/lib/Roundcube/rcube_plugin_api.php +++ b/program/lib/Roundcube/rcube_plugin_api.php @@ -36,6 +36,7 @@ class rcube_plugin_api public $task = ''; public $output; public $handlers = array(); + public $allowed_prefs = array(); protected $plugins = array(); protected $tasks = array(); @@ -202,6 +203,11 @@ class rcube_plugin_api $plugin->init(); $this->plugins[$plugin_name] = $plugin; } + + if (!empty($plugin->allowed_prefs)) { + $this->allowed_prefs = array_merge($this->allowed_prefs, $plugin->allowed_prefs); + } + return true; } } diff --git a/program/steps/utils/save_pref.inc b/program/steps/utils/save_pref.inc index b550ad7ef..7def8733d 100644 --- a/program/steps/utils/save_pref.inc +++ b/program/steps/utils/save_pref.inc @@ -21,6 +21,22 @@ $name = get_input_value('_name', RCUBE_INPUT_POST); $value = get_input_value('_value', RCUBE_INPUT_POST); +$whitelist = array( + 'preview_pane', + 'list_cols', + 'collapsed_folders', + 'collapsed_abooks', +); + +if (!in_array($name, array_merge($whitelist, $RCMAIL->plugins->allowed_prefs))) { + raise_error(array('code' => 500, 'type' => 'php', + 'file' => __FILE__, 'line' => __LINE__, + 'message' => sprintf("Hack attempt detected (user: %s)", $RCMAIL->get_user_name())), + true, false); + + $OUTPUT->reset(); + $OUTPUT->send(); +} // save preference value $RCMAIL->user->save_prefs(array($name => $value)); |