summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Smith <colin@pfsense.org>2005-06-16 00:59:51 +0000
committerColin Smith <colin@pfsense.org>2005-06-16 00:59:51 +0000
commit2a0e65173cf87724c7c5b74eb7f7d1fad664391f (patch)
treeb95bfe43c4fd465da3ef33c9c7d56aa18b684070
parentc1312033db05fb55dde0ccf262ddedb81d8f3d54 (diff)
downloadpfsense-2a0e65173cf87724c7c5b74eb7f7d1fad664391f.zip
pfsense-2a0e65173cf87724c7c5b74eb7f7d1fad664391f.tar.gz
* Add eval_once, which checks the md5s of code to eval() against already eval'ed blocks.
* eval -> eval_once when using package global functions. Tickets #160, #158
-rw-r--r--etc/inc/pkg-utils.inc25
1 files changed, 18 insertions, 7 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index a33ad9d..9e09ff5 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -449,6 +449,17 @@ function install_package($package, $pkg_info = "") {
update_output_window($static_output);
}
+function eval_once($toeval) {
+ global $evaled;
+ $evalmd5 = md5($toeval);
+ if(!in_array($evalmd5, $evaled)) {
+ eval($toeval);
+ $evaled[] = $evalmd5;
+ }
+ return;
+}
+
+
function install_package_xml($pkg) {
global $g, $config, $fd_log, $static_output;
if(($pkgid = get_pkg_id($pkg)) == -1) {
@@ -540,21 +551,21 @@ function install_package_xml($pkg) {
$static_output .= "\tCustom commands... ";
update_output_window($static_output);
if($pkg_config['custom_php_global_functions'] <> "") {
- eval($pkg_config['custom_php_global_functions']);
+ eval_once($pkg_config['custom_php_global_functions']);
}
fwrite($fd_log, "Executing post install commands...\n");
- eval($pkg_config['custom_php_install_command']);
+ eval_once($pkg_config['custom_php_install_command']);
$static_output .= "done.\n";
update_output_window($static_output);
}
/* call our before form property since we may be declaring functions
in it that are called later */
if($pkg_config['custom_php_command_before_form'] <> "") {
- eval($pkg_config['custom_php_command_before_form']);
+ eval_once($pkg_config['custom_php_command_before_form']);
}
/* call our resync function */
if($pkg_config['custom_php_resync_config_command'] <> "") {
- eval($pkg_config['custom_php_resync_config_command']);
+ eval_once($pkg_config['custom_php_resync_config_command']);
}
} else {
$static_output .= "Loading package configuration... failed!\n\nInstallation aborted.";
@@ -636,9 +647,9 @@ function delete_package_xml($pkg) {
}
/* evalate this package's global functions and pre deinstall commands */
if($pkg_config['custom_php_global_functions'] <> "")
- eval($pkg_config['custom_php_global_functions']);
+ eval_once($pkg_config['custom_php_global_functions']);
if($pkg_config['custom_php_pre_deinstall_command'] <> "")
- eval($pkg_config['custom_php_pre_deinstall_command']);
+ eval_once($pkg_config['custom_php_pre_deinstall_command']);
/* remove all additional files */
if($pkg_config['additional_files_needed'] <> "") {
$static_output .= "\tAuxiliary files... ";
@@ -679,7 +690,7 @@ function delete_package_xml($pkg) {
if($pkg_config['custom_php_deinstall_command'] <> "") {
$static_output .= "\tDeinstall commands... ";
update_output_window($static_output);
- eval($pkg_config['custom_php_deinstall_command']);
+ eval_once($pkg_config['custom_php_deinstall_command']);
$static_output .= "done.\n";
update_output_window($static_output);
}
OpenPOWER on IntegriCloud