diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-03-31 19:24:52 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-07 13:30:29 +0200 |
commit | dac94679c640a34f897802e9b61bcd871014e1ec (patch) | |
tree | e3f355f6bb3c37692b079ee90fac449620c99d4a /apps/encryption/lib/recovery.php | |
parent | ea6b53042d8464792c5ce7545d618f90128c914d (diff) | |
download | nextcloud-server-dac94679c640a34f897802e9b61bcd871014e1ec.tar.gz nextcloud-server-dac94679c640a34f897802e9b61bcd871014e1ec.zip |
delete recovery keys on disable
Diffstat (limited to 'apps/encryption/lib/recovery.php')
-rw-r--r-- | apps/encryption/lib/recovery.php | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/apps/encryption/lib/recovery.php b/apps/encryption/lib/recovery.php index b3da82a3cc5..00711e3bfab 100644 --- a/apps/encryption/lib/recovery.php +++ b/apps/encryption/lib/recovery.php @@ -182,7 +182,7 @@ class Recovery { if ($value === '1') { $this->addRecoveryKeys('/' . $this->user->getUID() . '/files/'); } else { - $this->removeRecoveryKeys(); + $this->removeRecoveryKeys('/' . $this->user->getUID() . '/files/'); } return true; @@ -194,10 +194,9 @@ class Recovery { /** * add recovery key to all encrypted files */ - private function addRecoveryKeys($path = '/') { + private function addRecoveryKeys($path) { $dirContent = $this->view->getDirectoryContent($path); foreach ($dirContent as $item) { - // get relative path from files_encryption/keyfiles/ $filePath = $item->getPath(); if ($item['type'] === 'dir') { $this->addRecoveryKeys($filePath . '/'); @@ -222,18 +221,14 @@ class Recovery { /** * remove recovery key to all encrypted files */ - private function removeRecoveryKeys($path = '/') { - return true; - $dirContent = $this->view->getDirectoryContent($this->keyfilesPath . $path); + private function removeRecoveryKeys($path) { + $dirContent = $this->view->getDirectoryContent($path); foreach ($dirContent as $item) { - // get relative path from files_encryption/keyfiles - $filePath = substr($item['path'], strlen('files_encryption/keyfiles')); + $filePath = $item->getPath(); if ($item['type'] === 'dir') { $this->removeRecoveryKeys($filePath . '/'); } else { - // remove '.key' extension from path e.g. 'file.txt.key' to 'file.txt' - $file = substr($filePath, 0, -4); - $this->view->unlink($this->shareKeysPath . '/' . $file . '.' . $this->recoveryKeyId . '.shareKey'); + $this->keyManager->deleteFileKey($filePath, $this->keyManager->getRecoveryKeyId() . '.shareKey'); } } } |