From f81085dfc016d0f4fa86b21e8d9b25aa1172e523 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 29 Mar 2017 09:28:02 +0200 Subject: [PATCH] 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. --- src/etc/inc/plugins.inc | 42 ++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/src/etc/inc/plugins.inc b/src/etc/inc/plugins.inc index e3ce5fad0..6da03d3d6 100644 --- a/src/etc/inc/plugins.inc +++ b/src/etc/inc/plugins.inc @@ -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) {