diff options
author | Renato Botelho <renato@netgate.com> | 2018-09-18 13:34:21 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2018-09-18 13:35:32 -0300 |
commit | 635ea24ecea4d2c866c2d16e2ca9b92eda0b7d93 (patch) | |
tree | 07bf2eac75193a2789d69cfa995f5a01d1e13eb9 | |
parent | d43485a9bc0fd7c5174090949290e4fc8100d565 (diff) | |
download | pfsense-635ea24ecea4d2c866c2d16e2ca9b92eda0b7d93.zip pfsense-635ea24ecea4d2c866c2d16e2ca9b92eda0b7d93.tar.gz |
Fix #8911: Keep configured pkg repository when restoring config
-rw-r--r-- | src/etc/inc/pfsense-utils.inc | 19 | ||||
-rw-r--r-- | src/usr/local/www/diag_backup.php | 22 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 5462a6f..50d3be6 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -934,10 +934,29 @@ function restore_config_section($section_name, $new_contents) { if ($section_xml === -1) { return false; } + + /* Save current pkg repo to re-add on new config */ + unset($pkg_repo_conf_path); + if ($section_name == "system" && + isset($config['system']['pkg_repo_conf_path'])) { + $pkg_repo_conf_path = $config['system']['pkg_repo_conf_path']; + } + $config[$section_name] = &$section_xml; if (file_exists("{$g['tmp_path']}/config.cache")) { unlink("{$g['tmp_path']}/config.cache"); } + + /* Restore previously pkg repo configured */ + if ($section_name == "system") { + if (isset($pkg_repo_conf_path)) { + $config['system']['pkg_repo_conf_path'] = + $pkg_repo_conf_path; + } elseif (isset($config['system']['pkg_repo_conf_path'])) { + unset($config['system']['pkg_repo_conf_path']); + } + } + write_config(sprintf(gettext("Restored %s of config file (maybe from CARP partner)"), $section_name)); disable_security_checks(); return true; diff --git a/src/usr/local/www/diag_backup.php b/src/usr/local/www/diag_backup.php index f4ada0e..afffae9 100644 --- a/src/usr/local/www/diag_backup.php +++ b/src/usr/local/www/diag_backup.php @@ -287,6 +287,12 @@ if ($_POST) { /* restore the entire configuration */ file_put_contents($_FILES['conffile']['tmp_name'], $data); if (config_install($_FILES['conffile']['tmp_name']) == 0) { + /* Save current pkg repo to re-add on new config */ + unset($pkg_repo_conf_path); + if (isset($config['system']['pkg_repo_conf_path'])) { + $pkg_repo_conf_path = $config['system']['pkg_repo_conf_path']; + } + /* this will be picked up by /index.php */ mark_subsystem_dirty("restore"); touch("/conf/needs_package_sync"); @@ -295,6 +301,22 @@ if ($_POST) { unlink("{$g['tmp_path']}/config.cache"); } $config = parse_config(true); + + /* Restore previously pkg repo configured */ + $pkg_repo_restored = false; + if (isset($pkg_repo_conf_path)) { + $config['system']['pkg_repo_conf_path'] = + $pkg_repo_conf_path; + $pkg_repo_restored = true; + } elseif (isset($config['system']['pkg_repo_conf_path'])) { + unset($config['system']['pkg_repo_conf_path']); + $pkg_repo_restored = true; + } + + if ($pkg_repo_restored) { + write_config(gettext("Removing pkg repository set after restoring full configuration")); + } + if (file_exists("/boot/loader.conf")) { $loaderconf = file_get_contents("/boot/loader.conf"); if (strpos($loaderconf, "console=\"comconsole")) { |