aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-08-23 16:50:16 -0400
committerScott Ullrich <sullrich@pfsense.org>2009-08-23 16:50:16 -0400
commit8f022a561a6e1cc3779edcf6089b0218c42a6d74 (patch)
tree29de6c75102adbb7799cbf930e4ace8d053ba4e8 /config
parentb39ab78a8cd15d93dad3e4f8819bb475f7a56be8 (diff)
downloadpfsense-packages-8f022a561a6e1cc3779edcf6089b0218c42a6d74.tar.gz
pfsense-packages-8f022a561a6e1cc3779edcf6089b0218c42a6d74.tar.bz2
pfsense-packages-8f022a561a6e1cc3779edcf6089b0218c42a6d74.zip
Unbreak ACB restore
Diffstat (limited to 'config')
-rw-r--r--config/autoconfigbackup/autoconfigbackup.inc2
-rw-r--r--config/autoconfigbackup/autoconfigbackup.php11
-rw-r--r--config/autoconfigbackup/crypt_acb.php10
3 files changed, 16 insertions, 7 deletions
diff --git a/config/autoconfigbackup/autoconfigbackup.inc b/config/autoconfigbackup/autoconfigbackup.inc
index 4522abda..2bd02769 100644
--- a/config/autoconfigbackup/autoconfigbackup.inc
+++ b/config/autoconfigbackup/autoconfigbackup.inc
@@ -155,8 +155,8 @@ function upload_config($reasonm = "") {
update_filter_reload_status($notice_text);
// Encrypt config.xml
- $raw_config_sha256_hash = trim(`/sbin/sha256 /cf/conf/config.xml | awk '{ print $4 }'`);
$data = file_get_contents("/cf/conf/config.xml");
+ $raw_config_sha256_hash = trim(`/sbin/sha256 /cf/conf/config.xml | awk '{ print $4 }'`);
$data = encrypt_data($data, $encryptpw);
tagfile_reformat($data, $data, "config.xml");
diff --git a/config/autoconfigbackup/autoconfigbackup.php b/config/autoconfigbackup/autoconfigbackup.php
index 116bb4bd..f0c5741d 100644
--- a/config/autoconfigbackup/autoconfigbackup.php
+++ b/config/autoconfigbackup/autoconfigbackup.php
@@ -195,7 +195,12 @@ function get_hostnames() {
$data = $data_split[1];
if (!tagfile_deformat($data, $data, "config.xml"))
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
- $data = decrypt_data($data, $decrypt_password);
+ $out = decrypt_data($data, $decrypt_password);
+
+ $pos = stripos($out, "</pfsense>");
+ $data = substr($out, 0, $pos);
+ $data = $data . "</pfsense>\n";
+
$fd = fopen("/tmp/config_restore.xml", "w");
fwrite($fd, $data);
fclose($fd);
@@ -204,7 +209,7 @@ function get_hostnames() {
$ondisksha256 = trim(`/sbin/sha256 /tmp/config_restore.xml | awk '{ print $4 }'`);
if($sha256 != "0" && $sha256 != "") // we might not have a sha256 on file for older backups
if($ondisksha256 <> $sha256)
- $input_errors[] = "SHA256 values do not match, cannot restore.";
+ $input_errors[] = "SHA256 values do not match, cannot restore. $ondisksha256 <> $sha256";
if (curl_errno($curl_session)) {
/* If an error occured, log the error in /tmp/ */
$fd = fopen("/tmp/acb_restoredebug.txt", "w");
@@ -233,7 +238,7 @@ EOF;
} else {
log_error("There was an error when restoring the AutoConfigBackup item");
}
- unlink("/tmp/config_restore.xml");
+ //unlink("/tmp/config_restore.xml");
}
if($_REQUEST['download']) {
// Phone home and obtain backups
diff --git a/config/autoconfigbackup/crypt_acb.php b/config/autoconfigbackup/crypt_acb.php
index 804b6a41..49a2147a 100644
--- a/config/autoconfigbackup/crypt_acb.php
+++ b/config/autoconfigbackup/crypt_acb.php
@@ -73,11 +73,11 @@
}
function encrypt_data(& $data, $pass) {
- return base64_encode(crypt_data($data, $pass, "-e"));
+ return trim(base64_encode(crypt_data($data, $pass, "-e")));
}
function decrypt_data(& $data, $pass) {
- return crypt_data(base64_decode($data), $pass, "-d");
+ return trim(crypt_data(base64_decode($data), $pass, "-d"));
}
function tagfile_reformat($in, & $out, $tag) {
@@ -93,7 +93,9 @@
$oset += $size;
}
- $out .= "---- END {$tag} ----\n";
+ $out .= "---- END {$tag} ----";
+
+ $out = trim($out);
return true;
}
@@ -119,6 +121,8 @@
$out = substr($in, $body_pos, $body_len);
+ $out = trim($out);
+
return true;
}