diff options
author | Ermal Luçi <eri@pfsense.org> | 2009-08-24 12:05:28 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2009-08-24 12:05:28 +0000 |
commit | da17d77e63068481522ad42cca8a020ca31ef639 (patch) | |
tree | cd4cf68ad91bee427c91f2499ccdd6df8dcab3ba /etc/inc/config.inc | |
parent | 8f192f4e81a83d52d46c26d7c78a228474dc4d07 (diff) | |
download | pfsense-da17d77e63068481522ad42cca8a020ca31ef639.zip pfsense-da17d77e63068481522ad42cca8a020ca31ef639.tar.gz |
* In config_install validate the file that will be installed not the already present config!
* Convert most hardcoded /tmp to the global variable
* Do not reboot the firewall under the hood without confirmation from the user after restoring. Just ask the user to do it.
* Fix various things in restore/backup code.
Diffstat (limited to 'etc/inc/config.inc')
-rw-r--r-- | etc/inc/config.inc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 31dad3c..a6f0925 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -337,10 +337,12 @@ function discover_last_backup() { } function restore_backup($file) { + global $g; + if (file_exists($file)) { conf_mount_rw(); copy("$file","/cf/conf/config.xml"); - unlink_if_exists("/tmp/config.cache"); + unlink_if_exists("{$g['tmp_path']}/config.cache"); 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(); @@ -699,7 +701,7 @@ function config_restore($conffile) { $lockkey = lock('config'); copy($conffile, "{$g['cf_conf_path']}/config.xml"); - unlink_if_exists("/tmp/config.cache"); + unlink_if_exists("{$g['tmp_path']}/config.cache"); unlock($lockkey); @@ -718,14 +720,16 @@ function config_install($conffile) { if (!file_exists($conffile)) return 1; - if (!config_validate("{$g['conf_path']}/config.xml")) + if (!config_validate("{$conffile}")) return 1; if($g['booting'] == true) echo "Installing configuration...\n"; + else + log_error("Installing configuration ...."); - $lockkey = lock('config'); conf_mount_rw(); + $lockkey = lock('config'); copy($conffile, "{$g['conf_path']}/config.xml"); @@ -733,8 +737,8 @@ function config_install($conffile) { if(file_exists("{$g['tmp_path']}/config.cache")) unlink("{$g['tmp_path']}/config.cache"); - conf_mount_ro(); unlock($lockkey); + conf_mount_ro(); return 0; } @@ -1319,4 +1323,4 @@ if($config_parsed == true) { } } -?>
\ No newline at end of file +?> |