aboutsummaryrefslogtreecommitdiffstats
path: root/config/autoconfigbackup
diff options
context:
space:
mode:
authorManuel Silvoso <msilvoso@gmail.com>2014-06-25 22:32:36 +0200
committerManuel Silvoso <msilvoso@gmail.com>2014-07-25 22:25:20 +0200
commitc4f7014bba0bb82b21025afe02f2ec04039e0cf2 (patch)
tree0b612fdf9fe21b862ca6cbb7e14a03cd023a3a25 /config/autoconfigbackup
parent653a43f2e113f28cc8226392bf9a5c0562a486ad (diff)
downloadpfsense-packages-c4f7014bba0bb82b21025afe02f2ec04039e0cf2.tar.gz
pfsense-packages-c4f7014bba0bb82b21025afe02f2ec04039e0cf2.tar.bz2
pfsense-packages-c4f7014bba0bb82b21025afe02f2ec04039e0cf2.zip
Tabs to spaces and merged changes from crypt.php into crypt_acb.php
Diffstat (limited to 'config/autoconfigbackup')
-rw-r--r--config/autoconfigbackup/autoconfigbackup.php8
-rw-r--r--config/autoconfigbackup/crypt_acb.php19
2 files changed, 15 insertions, 12 deletions
diff --git a/config/autoconfigbackup/autoconfigbackup.php b/config/autoconfigbackup/autoconfigbackup.php
index 94f835c0..9826154c 100644
--- a/config/autoconfigbackup/autoconfigbackup.php
+++ b/config/autoconfigbackup/autoconfigbackup.php
@@ -269,8 +269,8 @@ EOF;
"&hostname=" . urlencode($hostname) .
"&revision=" . urlencode($_REQUEST['download']));
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
- // Proxy
- curl_setopt_array($curl_session, configure_proxy($config));
+ // Proxy
+ curl_setopt_array($curl_session, configure_proxy($config));
$data = curl_exec($curl_session);
if (!tagfile_deformat($data, $data1, "config.xml"))
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
@@ -322,8 +322,8 @@ EOF;
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}");
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
- // Proxy
- curl_setopt_array($curl_session, configure_proxy($config));
+ // Proxy
+ curl_setopt_array($curl_session, configure_proxy($config));
$data = curl_exec($curl_session);
if (curl_errno($curl_session)) {
diff --git a/config/autoconfigbackup/crypt_acb.php b/config/autoconfigbackup/crypt_acb.php
index b0d8bebd..9f897cb5 100644
--- a/config/autoconfigbackup/crypt_acb.php
+++ b/config/autoconfigbackup/crypt_acb.php
@@ -31,14 +31,17 @@
function crypt_data($val, $pass, $opt) {
$file = tempnam("/tmp", "php-encrypt");
- $fd = fopen("$file.dec", "w");
- fwrite($fd, $val);
- fclose($fd);
- exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}");
- $result = file_get_contents("$file.enc");
- exec("rm $file");
- exec("rm $file.dec");
- exec("rm $file.enc");
+ file_put_contents("{$file}.dec", $val);
+ exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in {$file}.dec -out {$file}.enc -k " . escapeshellarg($pass));
+ if (file_exists("{$file}.enc"))
+ $result = file_get_contents("{$file}.enc");
+ else {
+ $result = "";
+ log_error("Failed to encrypt/decrypt data!");
+ }
+ @unlink($file);
+ @unlink("{$file}.dec");
+ @unlink("{$file}.enc");
return $result;
}