summaryrefslogtreecommitdiffstats
path: root/etc/inc/config.lib.inc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-05-18 19:27:57 +0000
committerErmal <eri@pfsense.org>2010-05-18 19:31:28 +0000
commite490f9950c965a878481dc830e99330fdb82837b (patch)
tree52bfec3c6fdf8f682057cc16055fc6f42e7f9141 /etc/inc/config.lib.inc
parent873b2f0c810b15dc649c2ce71a08a56f01e649a4 (diff)
downloadpfsense-e490f9950c965a878481dc830e99330fdb82837b.zip
pfsense-e490f9950c965a878481dc830e99330fdb82837b.tar.gz
Do not bail out when we write a new config. Seems that we can write some special characters but might not be able to read them back but we still should be able to recover from this. Include globals.inc before calling any config.lib.inc functions.
Diffstat (limited to 'etc/inc/config.lib.inc')
-rw-r--r--etc/inc/config.lib.inc19
1 files changed, 10 insertions, 9 deletions
diff --git a/etc/inc/config.lib.inc b/etc/inc/config.lib.inc
index 0fa2315..d4f4c88 100644
--- a/etc/inc/config.lib.inc
+++ b/etc/inc/config.lib.inc
@@ -191,8 +191,8 @@ function restore_backup($file) {
if (file_exists($file)) {
conf_mount_rw();
- copy("$file","/cf/conf/config.xml");
unlink_if_exists("{$g['tmp_path']}/config.cache");
+ copy("$file","/cf/conf/config.xml");
log_error("{$g['product_name']} is restoring the configuration $file");
file_notice("config.xml", "{$g['product_name']} is restoring the configuration $file", "pfSenseConfigurator", "");
conf_mount_ro();
@@ -496,13 +496,14 @@ function write_config($desc="Unknown", $backup = true) {
/* re-read configuration */
/* 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']);
-
- /* write config cache */
- $fd = @fopen("{$g['tmp_path']}/config.cache", "wb");
- if ($fd) {
- fwrite($fd, serialize($config));
- fclose($fd);
- }
+ 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."));
+ } else
+ generate_config_cache($config);
unlock($lockkey);
@@ -571,8 +572,8 @@ function config_restore($conffile) {
$lockkey = lock('config', LOCK_EX);
- copy($conffile, "{$g['cf_conf_path']}/config.xml");
unlink_if_exists("{$g['tmp_path']}/config.cache");
+ copy($conffile, "{$g['cf_conf_path']}/config.xml");
unlock($lockkey);
OpenPOWER on IntegriCloud