diff options
author | Renato Botelho <garga@FreeBSD.org> | 2014-08-26 18:54:53 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2014-08-26 18:54:53 -0300 |
commit | 613eba4dd146bcc0890b42e185bb2fda46dcef26 (patch) | |
tree | dd31129efb38b35d0419e423d96cda3da32934b6 /config/autoconfigbackup/crypt_acb.php | |
parent | 4d68442d89b78154f5f9cb46271e7e5527685a2c (diff) | |
parent | 2fb2c17eef49225706b2fb1d4bd522dea58ce982 (diff) | |
download | pfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.tar.gz pfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.tar.bz2 pfsense-packages-613eba4dd146bcc0890b42e185bb2fda46dcef26.zip |
Merge pull request #681 from msilvoso/master
Diffstat (limited to 'config/autoconfigbackup/crypt_acb.php')
-rw-r--r-- | config/autoconfigbackup/crypt_acb.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/config/autoconfigbackup/crypt_acb.php b/config/autoconfigbackup/crypt_acb.php index 49a2147a..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; } @@ -130,4 +133,3 @@ return strpos(strtolower($str), strtolower($needle)); } -?>
\ No newline at end of file |