diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2008-10-19 03:19:22 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2008-10-19 03:19:22 +0000 |
commit | 5025a56c9f3506a112155129ae787958762683f8 (patch) | |
tree | 1ad9d3a2ea409edde54f4c3bb8ded8565e2ca2eb /etc | |
parent | e7d967d8da9f1b418b9cc7e0bbe9f11e1285b787 (diff) | |
download | pfsense-5025a56c9f3506a112155129ae787958762683f8.zip pfsense-5025a56c9f3506a112155129ae787958762683f8.tar.gz |
* Add run_plugins() function
* Use run_plugins() function in filter.inc
* Add plugin hook for parse_config and write_config
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/cmd_chain.inc | 3 | ||||
-rw-r--r-- | etc/inc/config.inc | 52 | ||||
-rw-r--r-- | etc/inc/crypt.inc | 4 | ||||
-rw-r--r-- | etc/inc/filter.inc | 29 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 24 | ||||
-rw-r--r-- | etc/inc/pkg-utils.inc | 3 |
6 files changed, 89 insertions, 26 deletions
diff --git a/etc/inc/cmd_chain.inc b/etc/inc/cmd_chain.inc index 8186065..13bd913 100644 --- a/etc/inc/cmd_chain.inc +++ b/etc/inc/cmd_chain.inc @@ -120,8 +120,11 @@ Class CmdCHAIN { $cmdchain = new CmdCHAIN(); $cmdchain->add("grab freebsd version", "uname -a", false); $cmdchain->setdebug(); // optional for verbose logging +$cmdchain->nohaltonerror(); // tells cmdchain to keep processing commands if any of them fail $cmdchain->execute(); +$cmdchain->clear(); // clears the previous added entries + */ ?>
\ No newline at end of file diff --git a/etc/inc/config.inc b/etc/inc/config.inc index a0b514f..7eca3cc 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -203,6 +203,42 @@ EOD; mwexec("/sbin/mount -a"); } +/****f* config/encrypted_configxml + * NAME + * encrypted_configxml - Checks to see if config.xml is encrypted and if so, prompts to unlock. + * INPUTS + * None + * RESULT + * $config - rewrites config.xml without encryption + ******/ +function encrypted_configxml() { + global $g, $config; + if(file_exists($g['conf_path'] . "/config.xml")) { + if($g['booting']) { + $configtxt = file_get_contents($g['conf_path'] . "/config.xml"); + if(!tagfile_deformat($configtxt, $configtxt, "config.xml")) { + $fp = fopen('php://stdin', 'r'); + $data = ""; + echo "\n\n*** Encrypted config.xml detected ***\n"; + while($data == "") { + echo "\nEnter the password to decrypt config.xml: "; + $decrypt_password = chop(fgets($fp)); + $data = decrypt_data($configtxt, $decrypt_password); + if($data) { + $fd = fopen($g['conf_path'] . "/config.xml", "w"); + fwrite($fd, $data); + fclose($fd); + echo "\nConfig.xml unlocked.\n"; + fclose($fp); + } else { + echo "Invalid password entered. Please try again.\n"; + } + } + } + } + } +} + /****f* config/parse_config * NAME * parse_config - Read in config.cache or config.xml if needed and return $config array @@ -225,6 +261,8 @@ function parse_config($parse = false) { } if($g['booting']) echo "."; config_lock(); + // Check for encrypted config.xml + encrypted_configxml(); if(!$parse) { if(file_exists($g['tmp_path'] . '/config.cache')) { $config = unserialize(file_get_contents($g['tmp_path'] . '/config.cache')); @@ -270,6 +308,13 @@ function parse_config($parse = false) { alias_make_table($config); config_unlock(); + /* process packager manager custom rules */ + if(is_dir("/usr/local/pkg/config_parse/")) { + update_filter_reload_status("Running plugins (config_parse)"); + run_plugins("/usr/local/pkg/config_parse/"); + update_filter_reload_status("Plugins completed."); + } + /* override some global configuration parms if they exist * instead of hard coding these checks into the codebase */ @@ -2036,6 +2081,11 @@ function write_config($desc="Unknown", $backup = true) { config_unlock(); + /* process packager manager custom rules */ + update_filter_reload_status("Running plugins"); + run_plugins("/usr/local/pkg/write_config/"); + update_filter_reload_status("Plugins completed."); + return $config; } @@ -2867,4 +2917,4 @@ function set_device_perms() { if($g['booting']) echo "."; $config = parse_config(); -?> +?>
\ No newline at end of file diff --git a/etc/inc/crypt.inc b/etc/inc/crypt.inc index b9bbddd..8c56dca 100644 --- a/etc/inc/crypt.inc +++ b/etc/inc/crypt.inc @@ -1,4 +1,5 @@ <?php + /* $Id$ */ /* Copyright (C) 2008 Shrew Soft Inc @@ -99,4 +100,5 @@ return true; } -?> + +?>
\ No newline at end of file diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index b5f4e1c..7c0c4a9 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -252,30 +252,13 @@ function filter_configure_sync() { unlink("/tmp/commands.txt"); } - update_filter_reload_status("Running plugins"); - - /* process packager manager custom rules */ - $files = return_dir_as_array("/usr/local/pkg/pf/"); - if($files <> "") { - foreach ($files as $file) { - if($file) { - $text = file_get_contents("/usr/local/pkg/pf/" . $file); - if($text) { - if(stristr($file, ".sh") == true) { - mwexec("/usr/local/pkg/pf/" . $file . " start"); - } else { - if(!stristr($file,"CVS")) { - if($g['booting'] == true) - echo "\t{$file}... "; - require_once("/usr/local/pkg/pf/" . $file); - } - } - } - } - } + if(is_dir("/usr/local/pkg/pf/")) { + /* process packager manager custom rules */ + update_filter_reload_status("Running plugins (pf)"); + run_plugins("/usr/local/pkg/pf/"); + update_filter_reload_status("Plugins completed."); } - update_filter_reload_status("Plugins completed."); - + system_start_ftp_helpers(); /* if time based rules are enabled then swap in the set */ diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index bbd7737..15d1ab7 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2269,6 +2269,30 @@ function get_disk_info() { // $size, $used, $avail, $cap } +function run_plugins($directory) { + global $config, $g; + /* process packager manager custom rules */ + $files = return_dir_as_array($directory); + if($files <> "") { + foreach ($files as $file) { + if($file) { + $text = file_get_contents($directory . $file); + if($text) { + if(stristr($file, ".sh") == true) { + mwexec($directory . $file . " start"); + } else { + if(!stristr($file,"CVS")) { + if($g['booting'] == true) + echo "\t{$file}... "; + require_once($directory . $file); + } + } + } + } + } + } +} + /****f* pfsense-utils/display_top_tabs * NAME * display_top_tabs - display tabs with rounded edges diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index 60d099e..35ea943 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -948,4 +948,5 @@ function squash_from_bytes($size, $round = "") { } return; } -?> + +?>
\ No newline at end of file |