From d75c7f7e7476f0e166537e49a70aa446ed391251 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 21 Apr 2007 20:02:57 +0000 Subject: xmlparse now returns -1 when a file is corrupt. Detect this situation during parse_config() and trigger a backup. Note to the user this occurance. --- etc/inc/config.inc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'etc/inc/config.inc') diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 6bdfc36..a81a3d8 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -238,6 +238,13 @@ function parse_config($parse = false) { log_error("Could not restore config.xml."); } $config = parse_xml_config($g['conf_path'] . '/config.xml', $g['xml_rootobj']); + if($config == "-1") { + $last_backup = discover_last_backup(); + if ($last_backup) + restore_backup("/cf/conf/backup/{$last_backup}"); + else + log_error(gettext("Could not restore config.xml.")); + } generate_config_cache($config); } if($g['booting']) echo "."; @@ -293,6 +300,7 @@ function restore_backup($file) { if(file_exists($file)) { conf_mount_rw(); system("cp $file /cf/conf/config.xml"); + log_error("pfSense is restoring the configuration $file"); } } -- cgit v1.1