diff options
Diffstat (limited to 'apps/files_encryption')
-rw-r--r-- | apps/files_encryption/appinfo/info.xml | 4 | ||||
-rw-r--r-- | apps/files_encryption/hooks/hooks.php | 3 | ||||
-rw-r--r-- | apps/files_encryption/l10n/bn_BD.php | 3 | ||||
-rwxr-xr-x | apps/files_encryption/lib/crypt.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/lib/util.php | 16 | ||||
-rwxr-xr-x | apps/files_encryption/tests/util.php | 42 |
7 files changed, 68 insertions, 4 deletions
diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index e45715f5b20..2208cc73483 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -8,8 +8,8 @@ <requiremin>4</requiremin> <shipped>true</shipped> <documentation> - <user>http://doc.owncloud.org/server/6.0/user_manual/files/encryption.html</user> - <admin>http://doc.owncloud.org/server/6.0/admin_manual/configuration/configuration_encryption.html</admin> + <user>http://doc.owncloud.org/server/7.0/user_manual/files/encryption.html</user> + <admin>http://doc.owncloud.org/server/7.0/admin_manual/configuration/configuration_encryption.html</admin> </documentation> <rememberlogin>false</rememberlogin> <types> diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 1e605244f14..a6b4882083b 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -228,6 +228,9 @@ class Hooks { || !$util->userKeysExists()
|| !$view->file_exists($user . '/files')) {
+ // backup old keys
+ $util->backupAllKeys('recovery');
+
$newUserPassword = $params['password'];
// make sure that the users home is mounted
diff --git a/apps/files_encryption/l10n/bn_BD.php b/apps/files_encryption/l10n/bn_BD.php index 117f54ad8c8..8d034c83a15 100644 --- a/apps/files_encryption/l10n/bn_BD.php +++ b/apps/files_encryption/l10n/bn_BD.php @@ -12,6 +12,9 @@ $TRANSLATIONS = array( "Enabled" => "কার্যকর", "Disabled" => "অকার্যকর", "Change recovery key password:" => "পূণরূদ্ধার কি এর কুটশব্দ পরিবর্তন করুন:", +"Old Recovery key password" => "পূণরূদ্ধার কি এর পুরাতন কুটশব্দ", +"New Recovery key password" => "পূণরূদ্ধার কি এর নতুন কুটশব্দ", +"Repeat New Recovery key password" => "পূণরূদ্ধার কি এর নতুন কুটশব্দ পূণরায় দিন", "Change Password" => "কূটশব্দ পরিবর্তন করুন" ); $PLURAL_FORMS = "nplurals=2; plural=(n != 1);"; diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index 7974598729e..c4fc29db03a 100755 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -385,7 +385,7 @@ class Crypt { // openssl_seal returns false without errors if $plainContent
// is empty, so trigger our own error
if (empty($plainContent)) {
- throw new Exceptions\MultiKeyEncryptException('Cannot mutliKeyEncrypt empty plain content', 10);
+ throw new Exceptions\MultiKeyEncryptException('Cannot multiKeyEncrypt empty plain content', 10);
}
// Set empty vars to be set by openssl by reference
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 31d11338ef5..b406404a688 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -54,7 +54,7 @@ class Proxy extends \OC_FileProxy { $view = new \OC\Files\View(); // files outside of the files-folder are excluded - if(strpos($path, '/' . $uid . '/files') !== 0) { + if(strpos($path, '/' . $uid . '/files/') !== 0) { return true; } diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 087dada7f1b..33c2f88b0fd 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1478,6 +1478,22 @@ class Util { } /** + * create a backup of all keys from the user + * + * @param string $purpose (optional) define the purpose of the backup, will be part of the backup folder + */ + public function backupAllKeys($purpose = '') { + $this->userId; + $backupDir = $this->encryptionDir . '/backup.'; + $backupDir .= ($purpose === '') ? date("Y-m-d_H-i-s") . '/' : $purpose . '.' . date("Y-m-d_H-i-s") . '/'; + $this->view->mkdir($backupDir); + $this->view->copy($this->shareKeysPath, $backupDir . 'share-keys/'); + $this->view->copy($this->keyfilesPath, $backupDir . 'keyfiles/'); + $this->view->copy($this->privateKeyPath, $backupDir . $this->userId . '.private.key'); + $this->view->copy($this->publicKeyPath, $backupDir . $this->userId . '.public.key'); + } + + /** * check if the file is stored on a system wide mount point * @param string $path relative to /data/user with leading '/' * @return boolean diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index f337eb46355..f2db21be4c2 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -398,6 +398,48 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { } + /** + * test if all keys get moved to the backup folder correctly + */ + function testBackupAllKeys() { + self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1); + + // create some dummy key files + $encPath = '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '/files_encryption'; + $this->view->file_put_contents($encPath . '/keyfiles/foo.key', 'key'); + $this->view->file_put_contents($encPath . '/share-keys/foo.user1.shareKey', 'share key'); + + $util = new \OCA\Encryption\Util($this->view, self::TEST_ENCRYPTION_UTIL_USER1); + + $util->backupAllKeys('testing'); + + $encFolderContent = $this->view->getDirectoryContent($encPath); + + $backupPath = ''; + foreach ($encFolderContent as $c) { + $name = $c['name']; + if (substr($name, 0, strlen('backup')) === 'backup') { + $backupPath = $encPath . '/'. $c['name']; + break; + } + } + + $this->assertTrue($backupPath !== ''); + + // check backupDir Content + $this->assertTrue($this->view->is_dir($backupPath . '/keyfiles')); + $this->assertTrue($this->view->is_dir($backupPath . '/share-keys')); + $this->assertTrue($this->view->file_exists($backupPath . '/keyfiles/foo.key')); + $this->assertTrue($this->view->file_exists($backupPath . '/share-keys/foo.user1.shareKey')); + $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.private.key')); + $this->assertTrue($this->view->file_exists($backupPath . '/' . self::TEST_ENCRYPTION_UTIL_USER1 . '.public.key')); + + //cleanup + $this->view->deleteAll($backupPath); + $this->view->unlink($encPath . '/keyfiles/foo.key', 'key'); + $this->view->unlink($encPath . '/share-keys/foo.user1.shareKey', 'share key'); + } + function testDescryptAllWithBrokenFiles() { |