Commit ddcc54f4 authored by Franco Fichtner's avatar Franco Fichtner

plugins: lose the eval(), switch to include_once

Note that require_once is bad as well here, because it throws another
uncatched error as opposed to a warning when a file has not been found.
Now it is better in recovery, although 99% of the time this is supposed
to deal with syntax errors during bad core/plugin updates or manual
user edits.

It's also useful to note that the errors/warnings still make their way
to the crash reporter so we can do something about them.

Suggested by: @fabianfrz
parent f81085df
......@@ -71,11 +71,7 @@ function plugins_services()
$services = array();
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_services', $name);
if (function_exists($func)) {
$workers = $func();
......@@ -93,11 +89,7 @@ function plugins_cron()
$jobs = array();
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_cron', $name);
if (function_exists($func)) {
$workers = $func();
......@@ -115,11 +107,7 @@ function plugins_syslog()
$syslogs = array();
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_syslog', $name);
if (function_exists($func)) {
$workers = $func();
......@@ -154,11 +142,7 @@ function plugins_interfaces()
// register / update interfaces
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_interfaces', $name);
if (function_exists($func)) {
foreach ($func() as $intf_ref => $intf_data) {
......@@ -199,11 +183,7 @@ function plugins_interfaces()
function plugins_firewall($fw)
{
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_firewall', $name);
if (function_exists($func)) {
$func($fw);
......@@ -218,11 +198,7 @@ function plugins_configure($hook, $verbose = false, $args = array())
array_unshift($args, $verbose);
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_configure', $name);
if (function_exists($func)) {
$workers = $func();
......@@ -253,11 +229,7 @@ function plugins_xmlrpc_sync()
{
$sync_settings = array();
foreach (plugins_scan() as $name => $path) {
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
try { include_once $path; } catch (ParseError $e) { error_log($e); }
$func = sprintf('%s_xmlrpc_sync', $name);
if (function_exists($func)) {
foreach ($func() as $helper) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment