summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/config.lib.inc
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-05-03 10:02:17 +0545
committerPhil Davis <phil.davis@inf.org>2017-05-03 10:02:17 +0545
commit3dcaae882cdfdd86826be4db9b38ce04389701ec (patch)
tree7b1446642a6273dad12de10a4a8aecd90a51be4a /src/etc/inc/config.lib.inc
parentb090c7413ba2b53a1310b971d2efba1b3b9d7745 (diff)
downloadpfsense-3dcaae882cdfdd86826be4db9b38ce04389701ec.zip
pfsense-3dcaae882cdfdd86826be4db9b38ce04389701ec.tar.gz
Fix #7508 stop write_config after reset_factory_defaults
Diffstat (limited to 'src/etc/inc/config.lib.inc')
-rw-r--r--src/etc/inc/config.lib.inc22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/etc/inc/config.lib.inc b/src/etc/inc/config.lib.inc
index 252b3b2..40c3150 100644
--- a/src/etc/inc/config.lib.inc
+++ b/src/etc/inc/config.lib.inc
@@ -456,6 +456,15 @@ function write_config($desc="Unknown", $backup = true, $write_config_only = fals
}
}
+ if (isset($config['reset_factory_defaults'])) {
+ /*
+ We have put a default config.xml on disk and are about to reboot
+ or reload it. Do not let any system or package code try to save
+ state to config because that would overwrite the default config
+ with the running config.
+ */
+ return false;
+ }
if ($backup) {
backup_config();
@@ -525,7 +534,7 @@ function write_config($desc="Unknown", $backup = true, $write_config_only = fals
* integer - indicates completion
******/
function reset_factory_defaults($lock = false, $reboot_required = true) {
- global $g;
+ global $config, $g;
/* Remove all additional packages */
@@ -556,6 +565,17 @@ function reset_factory_defaults($lock = false, $reboot_required = true) {
disable_security_checks();
+ /*
+ Let write_config know that we are awaiting reload of the current config
+ to factory defaults. Either the system is about to reboot, throwing away
+ the current in-memory config as it shuts down, or the in-memory config
+ is about to be reloaded on-the-fly by parse_config.
+
+ In both cases, we want to ensure that write_config does not flush the
+ in-memory config back to disk.
+ */
+ $config['reset_factory_defaults'] = true;
+
/* call the wizard */
if ($reboot_required) {
// If we need a reboot first then touch a different trigger file.
OpenPOWER on IntegriCloud