summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/config.inc16
-rw-r--r--etc/inc/pfsense-utils.inc24
-rwxr-xr-xusr/local/www/diag_backup.php68
-rwxr-xr-xusr/local/www/guiconfig.inc4
4 files changed, 60 insertions, 52 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
+?>
diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php
index 50cb6d0..1660195 100755
--- a/usr/local/www/diag_backup.php
+++ b/usr/local/www/diag_backup.php
@@ -52,9 +52,10 @@ function add_base_packages_menu_items() {
$base_packages = split($g['base_packages'], ",");
$modified_config = false;
foreach($base_packages as $bp) {
- $basepkg_path = "/usr/local/pkg/";
- if(file_exists($basepkg_path . $configfile)) {
- $pkg_config = parse_xml_config_pkg($basepkg_path . $bp, "packagegui");
+ $basepkg_path = "/usr/local/pkg/{$bp}";
+ $tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
+ if($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
+ $pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
if($pkg_config['menu'] != "") {
if(is_array($pkg_config['menu'])) {
foreach($pkg_config['menu'] as $menu) {
@@ -130,6 +131,17 @@ function spit_out_select_items($area, $showall) {
}
+if ($_POST['apply']) {
+ ob_flush();
+ flush();
+ sleep(5);
+ conf_mount_rw();
+ clear_subsystem_dirty("restore");
+ conf_mount_ro();
+ mwexec("/sbin/shutdown -r now");
+ exit;
+}
+
if ($_POST) {
unset($input_errors);
if (stristr($_POST['Submit'], "Restore configuration"))
@@ -167,7 +179,7 @@ if ($_POST) {
$data = "";
if($options == "nopackages") {
- $sfn = "/tmp/config.xml.nopkg";
+ $sfn = "{$g['tmp_path']}/config.xml.nopkg";
exec("sed '/<installedpackages>/,/<\/installedpackages>/d' /conf/config.xml > {$sfn}");
$data = file_get_contents($sfn);
} else {
@@ -181,6 +193,8 @@ if ($_POST) {
}
}
+ unlock($lockbckp);
+
if ($_POST['encrypt']) {
$data = encrypt_data($data, $_POST['encrypt_password']);
tagfile_reformat($data, $data, "config.xml");
@@ -213,7 +227,6 @@ if ($_POST) {
header("Content-Length: $size");
echo $data;
- unlock($lockbckp);
exit;
}
}
@@ -271,14 +284,12 @@ if ($_POST) {
if (config_install($_FILES['conffile']['tmp_name']) == 0) {
/* this will be picked up by /index.php */
conf_mount_rw();
- if($g['platform'] <> "cdrom")
- touch("/needs_package_sync");
- $reboot_needed = true;
- $savemsg = "The configuration has been restored. The firewall is now rebooting.";
+ mark_subsystem_dirty("restore");
+ $savemsg = "The configuration has been restored. You need to reboot your firewall.";
touch("/conf/needs_package_sync");
/* remove cache, we will force a config reboot */
- if(file_exists("/tmp/config.cache"))
- unlink("/tmp/config.cache");
+ if(file_exists("{$g['tmp_path']}/config.cache"))
+ unlink("{$g['tmp_path']}/config.cache");
$config = parse_config(true);
/* extract out rrd items, unset from $confgi when done */
if($config['rrddata']) {
@@ -288,7 +299,7 @@ if ($_POST) {
fclose($rrd_fd);
}
unset($config['rrddata']);
- unlink_if_exists("/tmp/config.cache");
+ unlink_if_exists("{$g['tmp_path']}/config.cache");
write_config();
add_base_packages_menu_items();
convert_config();
@@ -304,23 +315,23 @@ if ($_POST) {
if(is_array($ifdescrs))
foreach($ifdescrs as $iface)
$config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']);
- unlink_if_exists("/tmp/config.cache");
+ unlink_if_exists("{$g['tmp_path']}/config.cache");
write_config();
add_base_packages_menu_items();
convert_config();
conf_mount_ro();
- $savemsg = "The m0n0wall configuration has been restored and upgraded to pfSense.<p>The firewall is now rebooting.";
- $reboot_needed = true;
+ $savemsg = "The m0n0wall configuration has been restored and upgraded to pfSense. You need to reboot your firewall.";
+ mark_subsystem_dirty("restore");
}
if(isset($config['captiveportal']['enable'])) {
/* for some reason ipfw doesn't init correctly except on bootup sequence */
- $savemsg = "The configuration has been restored.<p>The firewall is now rebooting.";
- $reboot_needed = true;
+ $savemsg = "The configuration has been restored. You need to reboot your firewall.";
+ mark_subsystem_dirty("restore");
}
setup_serial_port();
if(is_interface_mismatch() == true) {
touch("/var/run/interface_mismatch_reboot_needed");
- $reboot_needed = false;
+ clear_subsystem_dirty("restore");
header("Location: interfaces_assign.php");
exit;
}
@@ -344,8 +355,8 @@ if ($_POST) {
if ($ver2restore <> "") {
$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
if (config_install($conf_file) == 0) {
- $reboot_needed = true;
- $savemsg = "The configuration has been restored. The firewall is now rebooting.";
+ mark_subsystem_dirty("restore");
+ $savemsg = "The configuration has been restored. You need to reboot your firewall.";
} else {
$input_errors[] = "The configuration could not be restored.";
}
@@ -392,6 +403,9 @@ function decrypt_change() {
<form action="diag_backup.php" method="post" name="iform" enctype="multipart/form-data">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php if (is_subsystem_dirty('restore')): ?><p>
+<?php print_info_box_np("The firewall configuration has been changed.<br>You must click the apply button to restart the firewall in order for it to take effect.");?><br>
+<?php endif; ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
@@ -538,17 +552,3 @@ decrypt_change();
<?php include("fend.inc"); ?>
</body>
</html>
-
-<?php
-
-if($reboot_needed == true) {
- ob_flush();
- flush();
- sleep(5);
- while(file_exists("{$g['varrun_path']}/config.lock"))
- sleep(3);
- mwexec("/sbin/shutdown -r now");
- exit;
-}
-
-?>
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc
index 9880f7f..ebb1e35 100755
--- a/usr/local/www/guiconfig.inc
+++ b/usr/local/www/guiconfig.inc
@@ -250,7 +250,7 @@ function verify_gzip_file($fname) {
function print_info_box_np($msg, $name="apply",$value="Apply changes") {
global $g;
- if(stristr($msg, "apply") == true || stristr($msg, "save") || stristr($msg, "create")) {
+ if(stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) {
$savebutton = "<td class='infoboxsave'>";
$savebutton .= "<input name=\"{$name}\" type=\"submit\" class=\"formbtn\" id=\"${name}\" value=\"{$value}\">";
if($_POST['if'])
@@ -972,4 +972,4 @@ function rule_popup($src,$srcport,$dst,$dstport){
}
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud