summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2010-07-27 20:01:10 -0400
committerScott Ullrich <sullrich@pfsense.org>2010-07-27 20:01:53 -0400
commit4e9a3392139167cc834c7248e4ff6bb09aad7e88 (patch)
tree9b60964bd1e45d24889251a22aa0393cbd90051e /etc
parent2cdd52cc386a358d4bc269c884898312f5344622 (diff)
downloadpfsense-4e9a3392139167cc834c7248e4ff6bb09aad7e88.zip
pfsense-4e9a3392139167cc834c7248e4ff6bb09aad7e88.tar.gz
If config.extra.xml exists parse and merge its contents into the array as long as we are not writing out the config.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/config.lib.inc38
1 files changed, 34 insertions, 4 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 707dee8..10ec89a 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -90,8 +90,8 @@ function encrypted_configxml() {
* RESULT
* $config - array containing all configuration variables
******/
-function parse_config($parse = false) {
- global $g, $config_parsed;
+function parse_config($parse = false, $parse_extra = true) {
+ global $g, $config_parsed, $config_extra;
$lockkey = lock('config');
$config_parsed = false;
@@ -152,6 +152,26 @@ function parse_config($parse = false) {
}
generate_config_cache($config);
}
+ /*
+ * This is used for external management system add-ons
+ * allowing for example multiple configuration sections
+ * from a remote management system that does not clobber
+ * the system specific configuration. This routine
+ * merges the extra configuration data into $config
+ * and allows for external management systems to
+ * automatically configure specific services, etc.
+ */
+ if(file_exists($g['conf_path'] . "/config.extra.xml") && $parse_extra) {
+ if(file_exists($g['tmp_path'] . '/config.extra.cache')) {
+ $config_extra = unserialize(file_get_contents($g['tmp_path'] . '/config.extra.cache'));
+ } else {
+ if($g['booting']) echo ".";
+ $config_extra = parse_xml_config($g['conf_path'] . '/config.extra.xml', $g['xml_rootobj']);
+ if($g['booting']) echo ".";
+ $config = array_merge($config, $config_extra);
+ if($g['booting']) echo ".";
+ }
+ }
if($g['booting']) echo ".";
alias_make_table($config);
$config_parsed = true;
@@ -169,11 +189,19 @@ function parse_config($parse = false) {
* boolean - true on completion
******/
function generate_config_cache($config) {
- global $g;
+ global $g, $config_extra;
$configcache = fopen($g['tmp_path'] . '/config.cache', "w");
fwrite($configcache, serialize($config));
fclose($configcache);
+ unset($configcache);
+ /* Used for config.extra.xml */
+ if(file_exists($g['tmp_path'] . '/config.extra.cache') && $config_extra) {
+ $configcacheextra = fopen($g['tmp_path'] . '/config.extra.cache', "w");
+ fwrite($configcacheextra, serialize($config_extra));
+ fclose($configcacheextra);
+ unset($configcacheextra);
+ }
}
function discover_last_backup() {
@@ -457,6 +485,8 @@ function safe_write_file($file, $content, $force_binary) {
function write_config($desc="Unknown", $backup = true) {
global $config, $g;
+ $config = parse_config(true, false, false);
+
if($g['bootup'])
log_error("WARNING! Configuration written on bootup. This can cause stray openvpn and load balancing items in config.xml");
@@ -1277,4 +1307,4 @@ function set_device_perms() {
}
}
-?>
+?> \ No newline at end of file
OpenPOWER on IntegriCloud