From 832f1b83da1c42a7873556fdfc8f0c4e9dab2a90 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 12 Mar 2005 20:22:50 +0000 Subject: Correctly backup and restore config sections. --- etc/inc/pfsense-utils.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'etc') diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 2ef5b9f..28f3cee 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -732,11 +732,14 @@ function is_service_running($service_name) { } /* - * backup_config_section($section): returns as an array the configuration section + * backup_config_section($section): returns as an xml file string of + * the configuration section */ function backup_config_section($section) { global $config; $new_section = &$config['section']; + /* generate configuration XML */ + $xmlconfig = dump_xml_config($new_section, $section); return $new_section; } @@ -749,7 +752,12 @@ function restore_config_section($section, $new_contents) { global $config; conf_mount_rw(); config_lock(); - $config[$section] = &$new_contents; + $fout = fopen("{$g['tmp_path']}/tmpxml","w"); + fwrite($fout, $current_rules_section); + fclose($fout); + $section_xml = parse_xml_config_pkg($g['tmp_path'] . "/tmpxml", "packagegui"); + $config[$section] = &$section_xml; + unlink($g['tmp_path'] . "/tmpxml"); write_config(); conf_mount_ro(); config_unlock(); -- cgit v1.1