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 | |
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')
-rw-r--r-- | etc/inc/config.inc | 16 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 24 |
2 files changed, 24 insertions, 16 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 +?> diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index bd279a7..69e65bc 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -128,7 +128,8 @@ function is_private_ip($iptocheck) { * returns a temporary filename ******/ function get_tmp_file() { - return "/tmp/tmp-" . time(); + global $g; + return "{$g['tmp_path']}/tmp-" . time(); } /****f* pfsense-utils/find_number_of_needed_carp_interfaces @@ -893,9 +894,10 @@ Content-Length: $content_length * php_check_syntax($code_tocheck, $errormessage): checks $code_to_check for errors */ if (!function_exists('php_check_syntax')){ + global $g; function php_check_syntax($code_to_check, &$errormessage){ return false; - $fout = fopen("/tmp/codetocheck.php","w"); + $fout = fopen("{$g['tmp_path']}/codetocheck.php","w"); $code = $_POST['content']; $code = str_replace("<?php", "", $code); $code = str_replace("?>", "", $code); @@ -903,7 +905,7 @@ if (!function_exists('php_check_syntax')){ fwrite($fout, $code_to_check); fwrite($fout, "\n\n?>\n"); fclose($fout); - $command = "/usr/local/bin/php -l /tmp/codetocheck.php"; + $command = "/usr/local/bin/php -l {$g['tmp_path']}/codetocheck.php"; $output = exec_command($command); if (stristr($output, "Errors parsing") == false) { echo "false\n"; @@ -1084,7 +1086,7 @@ function reload_interfaces_sync() { log_error("Removing {$g['tmp_path']}/reloading_all"); /* start devd back up */ - mwexec("/bin/rm /tmp/reload*"); + mwexec("/bin/rm {$g['tmp_path']}/reload*"); } /****f* pfsense-utils/reload_all @@ -1096,7 +1098,8 @@ function reload_interfaces_sync() { * none ******/ function reload_all() { - touch("/tmp/reload_all"); + global $g; + touch("{$g['tmp_path']}/reload_all"); } /****f* pfsense-utils/reload_interfaces @@ -1108,7 +1111,8 @@ function reload_all() { * none ******/ function reload_interfaces() { - touch("/tmp/reload_interfaces"); + global $g; + touch("{$g['tmp_path']}/reload_interfaces"); } /****f* pfsense-utils/reload_all_sync @@ -1167,12 +1171,12 @@ function reload_all_sync() { conf_mount_ro(); /* restart sshd */ - @touch("/tmp/start_sshd"); + @touch("{$g['tmp_path']}/start_sshd"); /* restart webConfigurator if needed */ - touch("/tmp/restart_webgui"); + touch("{$g['tmp_path']}/restart_webgui"); - mwexec("/bin/rm /tmp/reload*"); + mwexec("/bin/rm {$g['tmp_path']}/reload*"); } function auto_login($status) { @@ -1780,4 +1784,4 @@ function update_progress_bar($percent) { } } -?>
\ No newline at end of file +?> |