summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-05-13 09:25:16 -0400
committerBjörn Schießle <schiessle@owncloud.com>2014-05-13 09:25:16 -0400
commitb8de1e5d716c416beae328506e368cd0554509e1 (patch)
tree8b13942c27547f4c4266699efc445b0bfe96296d /apps/files_encryption
parente934129bf6125c50ccede651b544d7ab07d5378a (diff)
parenta9ac11718e62017c70682f99eb35b43b1ef9c498 (diff)
downloadnextcloud-server-b8de1e5d716c416beae328506e368cd0554509e1.tar.gz
nextcloud-server-b8de1e5d716c416beae328506e368cd0554509e1.zip
Merge pull request #8398 from owncloud/enc_backup_keys
backup the encryption key after the encryption was disabled
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/lib/util.php4
-rwxr-xr-xapps/files_encryption/tests/util.php11
2 files changed, 13 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 37fdcaceaa5..b96e4590507 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -788,8 +788,8 @@ class Util {
}
if ($successful) {
- $this->view->deleteAll($this->keyfilesPath);
- $this->view->deleteAll($this->shareKeysPath);
+ $this->view->rename($this->keyfilesPath, $this->keyfilesPath . '.backup');
+ $this->view->rename($this->shareKeysPath, $this->shareKeysPath . '.backup');
}
\OC_FileProxy::$enabled = true;
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index de83f6bca2b..11961f27675 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -413,8 +413,16 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// file should no longer be encrypted
$this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
+ // check if the keys where moved to the backup location
+ $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/keyfiles.backup'));
+ $this->assertTrue($this->view->file_exists($this->userId . '/files_encryption/keyfiles.backup/' . $filename . '.key'));
+ $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/share-keys.backup'));
+ $this->assertTrue($this->view->file_exists($this->userId . '/files_encryption/share-keys.backup/' . $filename . '.' . $user . '.shareKey'));
+
// cleanup
$this->view->unlink($this->userId . '/files/' . $filename);
+ $this->view->deleteAll($this->userId . '/files_encryption/keyfiles.backup');
+ $this->view->deleteAll($this->userId . '/files_encryption/share-keys.backup');
OC_App::enable('files_encryption');
}
@@ -485,8 +493,11 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/keyfiles/'));
$this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/share-keys/'));
+ //cleanup
$this->view->unlink($this->userId . '/files/' . $file1);
$this->view->unlink($this->userId . '/files/' . $file2);
+ $this->view->deleteAll($this->userId . '/files_encryption/keyfiles.backup');
+ $this->view->deleteAll($this->userId . '/files_encryption/share-keys.backup');
}