From 38e5da05afede2e6dcd5465f47b3e4576ad37d64 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 9 Oct 2013 15:56:21 +0200 Subject: only encrypt file to users with encryption keys --- apps/files_encryption/hooks/hooks.php | 2 -- apps/files_encryption/lib/stream.php | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 2df860a8e57..d9a76becf25 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -92,8 +92,6 @@ class Hooks { } // Encrypt existing user files: - // This serves to upgrade old versions of the encryption - // app (see appinfo/spec.txt) if ( $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']) ) { diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index 02955bb064e..b25ba7bb677 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -506,9 +506,10 @@ class Stream { // Get all users sharing the file includes current user $uniqueUserIds = $util->getSharingUsersArray($sharingEnabled, $this->relPath, $this->userId); + $checkedUserIds = $util->filterShareReadyUsers($uniqueUserIds); // Fetch public keys for all sharing users - $publicKeys = Keymanager::getPublicKeys($this->rootView, $uniqueUserIds); + $publicKeys = Keymanager::getPublicKeys($this->rootView, $checkedUserIds['ready']); // Encrypt enc key for all sharing users $this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys); -- cgit v1.2.3 From a1719deabed4296c7daec51d926640100ac94980 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 10 Oct 2013 10:47:35 +0200 Subject: make sure that we are logged in ad user1 while performing the tests --- apps/files_sharing/tests/api.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/files_sharing/tests/api.php b/apps/files_sharing/tests/api.php index c55c186f089..2feea9e7e24 100644 --- a/apps/files_sharing/tests/api.php +++ b/apps/files_sharing/tests/api.php @@ -58,6 +58,10 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase { } function setUp() { + + //login as user1 + \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1); + $this->data = 'foobar'; $this->view = new \OC_FilesystemView('/' . \Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1 . '/files'); @@ -104,9 +108,6 @@ class Test_Files_Sharing_Api extends \PHPUnit_Framework_TestCase { */ function testCreateShare() { - //login as user1 - \Test_Files_Sharing_Api::loginHelper(\Test_Files_Sharing_Api::TEST_FILES_SHARING_API_USER1); - // share to user // simulate a post request -- cgit v1.2.3 From 909af2b62e75d1a5db866466074f2bcb95b864dc Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 10 Oct 2013 15:02:52 +0200 Subject: don't cache if the encryption is enabled, this can lead to problems during unit testing --- apps/files_encryption/lib/proxy.php | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'apps') diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 6f630c83a3f..8621c1ba51d 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -38,8 +38,6 @@ class Proxy extends \OC_FileProxy { private static $blackList = null; //mimetypes blacklisted from encryption - private static $enableEncryption = null; - /** * Check if a file requires encryption * @param string $path @@ -49,46 +47,22 @@ class Proxy extends \OC_FileProxy { */ private static function shouldEncrypt($path) { - if (is_null(self::$enableEncryption)) { - if ( - \OCP\App::isEnabled('files_encryption') === true - && Crypt::mode() === 'server' - ) { - - self::$enableEncryption = true; - - } else { - - self::$enableEncryption = false; - - } - - } - - if (!self::$enableEncryption) { - + if (\OCP\App::isEnabled('files_encryption') === false || Crypt::mode() !== 'server') { return false; - } if (is_null(self::$blackList)) { - self::$blackList = explode(',', \OCP\Config::getAppValue('files_encryption', 'type_blacklist', '')); - } if (Crypt::isCatfileContent($path)) { - return true; - } $extension = substr($path, strrpos($path, '.') + 1); if (array_search($extension, self::$blackList) === false) { - return true; - } return false; -- cgit v1.2.3