summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib')
-rw-r--r--apps/files_encryption/lib/proxy.php12
-rw-r--r--apps/files_encryption/lib/stream.php9
2 files changed, 15 insertions, 6 deletions
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 269521857b2..e3e2161a141 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -183,18 +183,23 @@ class Proxy extends \OC_FileProxy {
// If file is encrypted, decrypt using crypto protocol
if ( Crypt::mode() == 'server' && $util->isEncryptedPath( $path ) ) {
- file_put_contents('/home/samtuke/newtmp.txt', "bar" );
-
$tmp = fopen( 'php://temp' );
\OCP\Files::streamCopy( $result, $tmp );
fclose( $result );
+ $encrypted = $view->file_get_contents( $path );
+
+ //file_put_contents('/home/samtuke/newtmp.txt', "\$path = $path, \$data = $data" );
+
+ // Replace the contents of
\OC_Filesystem::file_put_contents( $path, $tmp );
fclose( $tmp );
+ //file_put_contents('/home/samtuke/newtmp.txt', file_get_contents( 'crypt://' . $path ) );
+
$result = fopen( 'crypt://' . $path, $meta['mode'] );
// file_put_contents('/home/samtuke/newtmp.txt', "mode= server" );
@@ -242,6 +247,9 @@ class Proxy extends \OC_FileProxy {
}*/
+ // Re-enable the proxy
+ \OC_FileProxy::$enabled = true;
+
return $result;
}
diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php
index 8264c507bda..2e3cdaabe44 100644
--- a/apps/files_encryption/lib/stream.php
+++ b/apps/files_encryption/lib/stream.php
@@ -31,6 +31,7 @@ namespace OCA\Encryption;
/**
* @brief Provides 'crypt://' stream wrapper protocol.
+ * @note We use a stream wrapper because it is the most secure way to handle decrypted content transfers. There is no safe way to decrypt the entire file somewhere on the server, so we have to encrypt and decrypt blocks on the fly.
* @note Paths used with this protocol MUST BE RELATIVE, due to limitations of OC_FilesystemView. crypt:///home/user/owncloud/data <- will put keyfiles in [owncloud]/data/user/files_encryption/keyfiles/home/user/owncloud/data and will not be accessible by other functions.
* @note Data read and written must always be 8192 bytes long, as this is the buffer size used internally by PHP. The encryption process makes the input data longer, and input is chunked into smaller pieces in order to result in a 8192 encrypted block size.
*/
@@ -52,6 +53,8 @@ class Stream {
public function stream_open( $path, $mode, $options, &$opened_path ) {
+ file_put_contents('/home/samtuke/newtmp.txt', 'stream_open('.$path.')' );
+
// Get access to filesystem via filesystemview object
if ( !self::$view ) {
@@ -141,9 +144,7 @@ class Stream {
public function stream_read( $count ) {
- trigger_error("\$count = $count");
-
- file_put_contents('/home/samtuke/newtmp.txt', "\$count = $count" );
+// file_put_contents('/home/samtuke/newtmp.txt', "\$count = $count" );
$this->writeCache = '';
@@ -275,7 +276,7 @@ class Stream {
*/
public function stream_write( $data ) {
- //file_put_contents('/home/samtuke/newtmp.txt', 'stream_write('.$data.')' );
+// file_put_contents('/home/samtuke/newtmp.txt', 'stream_write('.$data.')' );
// Disable the file proxies so that encryption is not automatically attempted when the file is written to disk - we are handling that separately here and we don't want to get into an infinite loop
\OC_FileProxy::$enabled = false;