summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2011-04-06 12:54:18 -0400
committerjim-p <jimp@pfsense.org>2011-04-06 12:55:32 -0400
commit557300a7eb66a82d951d5696c80209593cccfd6f (patch)
tree341acf2c2f7269a87f1ad9bf2e748657a5f924fc /etc/inc
parent4c613f84820a88c9b047e554b200accab5201f24 (diff)
downloadpfsense-557300a7eb66a82d951d5696c80209593cccfd6f.zip
pfsense-557300a7eb66a82d951d5696c80209593cccfd6f.tar.gz
Actually re-parse the config if a valid config was not written. (Should help stop installs from blowing up on failed config upgrades). Save the bad config for inspection, and print a message to the console about what was done.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/config.lib.inc11
1 files changed, 9 insertions, 2 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 1b7766a..8b25a3a 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -534,10 +534,17 @@ function write_config($desc="Unknown", $backup = true) {
/* NOTE: We assume that the file can be parsed since we wrote it. */
$config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
if ($config == -1) {
+ copy("{$g['conf_path']}/config.xml", "{$g['conf_path']}/config.xml.bad");
$last_backup = discover_last_backup();
- if ($last_backup)
+ if ($last_backup) {
restore_backup("/cf/conf/backup/{$last_backup}");
- else
+ $config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
+ if ($g['booting']) {
+ echo "\n\n ************** WARNING **************";
+ echo "\n\n New configuration could not be validated. Restored previous configuration. \n";
+ echo "\n Failed configuration has been saved as {{$g['conf_path']}/config.xml.bad} \n\n";
+ }
+ } else
log_error(gettext("Could not restore config.xml."));
} else
generate_config_cache($config);
OpenPOWER on IntegriCloud