From 83cda9769a5f00c507c3900f6ee2ccb2f385f800 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 24 Jan 2007 23:32:15 +0000 Subject: [PATCH] Add pfsense.merge_config_section which can merge two keys together via XMLRPC sync instead of killing the prior section. This is useful when merging subkeys of installedpackets for example. --- etc/inc/pfsense-utils.inc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 0cd6e625f8..190ce10a5c 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1103,6 +1103,27 @@ function restore_config_section($section, $new_contents) { return; } +/* + * merge_config_section($section, new_contents): restore a configuration section, + * and write the configuration out + * to disk/cf. But preserve the prior + * structure if needed + */ +function merge_config_section($section, $new_contents) { + global $config; + conf_mount_rw(); + $fname = get_tmp_filename(); + $fout = fopen($fname, "w"); + fwrite($fout, $new_contents); + fclose($fout); + $section_xml = parse_xml_config($fname, $section); + $config[$section] = $section_xml; + unlink($fname); + write_config("Restored {$section} of config file (maybe from CARP partner)"); + conf_mount_ro(); + return; +} + /* * http_post($server, $port, $url, $vars): does an http post to a web server * posting the vars array.