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