aboutsummaryrefslogtreecommitdiffstats
path: root/packages/autoconfigbackup
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-10-08 17:37:56 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-10-08 17:37:56 +0000
commit3b01505e656b1db5f9baff19620c5867cb77de63 (patch)
tree0a98e6248c63cea963ebc9921f70c44510c2297c /packages/autoconfigbackup
parent8ece67c74df50b4ebd00121eccea788718e83d43 (diff)
downloadpfsense-packages-3b01505e656b1db5f9baff19620c5867cb77de63.tar.gz
pfsense-packages-3b01505e656b1db5f9baff19620c5867cb77de63.tar.bz2
pfsense-packages-3b01505e656b1db5f9baff19620c5867cb77de63.zip
Revise crypt_data() a bit to avoid hanging
Diffstat (limited to 'packages/autoconfigbackup')
-rw-r--r--packages/autoconfigbackup/crypt_acb.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/packages/autoconfigbackup/crypt_acb.php b/packages/autoconfigbackup/crypt_acb.php
index 2fa5fc64..22a40ae2 100644
--- a/packages/autoconfigbackup/crypt_acb.php
+++ b/packages/autoconfigbackup/crypt_acb.php
@@ -29,24 +29,46 @@
DISABLE_PHP_LINT_CHECKING
*/
- function crypt_data(& $data, $pass, $opt) {
+ function crypt_data($val, $pass) {
+ $val = str_replace("'", "#%$", $val);
+ $file = tempnam('','php-encrypt-');
+ exec("echo -E '$val' > $file.dec");
+ exec("/usr/bin/openssl enc {$opt} -aes-256-cbc -in $file.dec -out $file.enc -k {$pass}");
+ $myfile = file("$file.enc");
+ exec("rm $file");
+ exec("rm $file.dec");
+ exec("rm $file.enc");
+ while (list($line_num, $line) = each($myfile)) {
+ $result .= $line;
+ }
+ $result = base64_encode($result);
+ $result = urlencode($result);
+ return $result;
+ }
+ function crypt_dataA(& $data, $pass, $opt) {
+ log_error("entering crypt_data()");
$pspec = "/usr/bin/openssl enc {$opt} -aes-256-cbc -k {$pass}";
$dspec = array( 0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "e"));
-
+ log_error("proc_open");
$fp = proc_open($pspec, $dspec, $pipes);
if (!$fp)
return false;
-
+ log_error("writing to pipe[0]");
fwrite($pipes[0], $data);
+ log_error("closing pipe[0]");
fclose($pipes[0]);
-
+
+ log_error("enter while()");
+
while (!feof($pipes[1])) {
$rslt .= fread($pipes[1], 8192);
}
-
+
+ log_error("exit while()");
+
fclose($pipes[1]);
proc_close($fp);