plugins: if a component has a faulty syntax...

simply eval() it and log the error instead of stopping execution.

We don't get to source the code, but since for strict plugins
there is no direct code execution the plugin acts as if it was
deinstalled.

As the plugin scope is growing rapidly, we need this to be able to
guarantee error-free execution in the widest possible sense.  This
doesn't currently protect function calls, but the same thing must
be done there as well.
This commit is contained in:
Franco Fichtner 2017-03-29 09:28:02 +02:00
parent 264c5655c4
commit f81085dfc0

View File

@ -71,7 +71,11 @@ function plugins_services()
$services = array();
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_services', $name);
if (function_exists($func)) {
$workers = $func();
@ -89,7 +93,11 @@ function plugins_cron()
$jobs = array();
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_cron', $name);
if (function_exists($func)) {
$workers = $func();
@ -107,7 +115,11 @@ function plugins_syslog()
$syslogs = array();
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_syslog', $name);
if (function_exists($func)) {
$workers = $func();
@ -142,7 +154,11 @@ function plugins_interfaces()
// register / update interfaces
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_interfaces', $name);
if (function_exists($func)) {
foreach ($func() as $intf_ref => $intf_data) {
@ -183,7 +199,11 @@ function plugins_interfaces()
function plugins_firewall($fw)
{
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_firewall', $name);
if (function_exists($func)) {
$func($fw);
@ -198,7 +218,11 @@ function plugins_configure($hook, $verbose = false, $args = array())
array_unshift($args, $verbose);
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_configure', $name);
if (function_exists($func)) {
$workers = $func();
@ -229,7 +253,11 @@ function plugins_xmlrpc_sync()
{
$sync_settings = array();
foreach (plugins_scan() as $name => $path) {
require_once $path;
try {
eval('require_once \'' . addslashes($path) . '\';');
} catch (ParseError $e) {
error_log($e);
}
$func = sprintf('%s_xmlrpc_sync', $name);
if (function_exists($func)) {
foreach ($func() as $helper) {