Skip to content

Commit

Permalink
[stable10] Remove alternate keys storage during user delete
Browse files Browse the repository at this point in the history
When user is deleted the alternate key storage location
does have folder with username. So while deleting user
this should also be cleaned up.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
  • Loading branch information
sharidas committed Oct 6, 2017
1 parent 46b3ec6 commit e05d242
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/encryption/lib/Hooks/UserHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,14 @@ public function postCreateUser($params) {
public function postDeleteUser($params) {

if (App::isEnabled('encryption')) {
$this->keyManager->deletePublicKey($params['uid']);
/**
* Adding a safe condition to make sure the uid is not
* empty or null.
*/
if (!is_null($params['uid']) && ($params['uid'] !== '')) {
$this->keyManager->deletePublicKey($params['uid']);
\OC::$server->getEncryptionKeyStorage()->deleteAltUserStorageKeys($params['uid']);
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions lib/private/Encryption/Keys/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,27 @@ public function deleteSystemUserKey($keyId, $encryptionModuleId) {
return !$this->view->file_exists($path) || $this->view->unlink($path);
}

/**
* @inheritdoc
*/

public function deleteAltUserStorageKeys($uid) {
if (\OC::$server->getEncryptionManager()->isEnabled()) {
/**
* If the key storage is not the default
* location, then we need to remove the keys
* in the alternate key location
*/
$keyStorageRoot = $this->util->getKeyStorageRoot();
if ($keyStorageRoot !== '') {
$this->view->rmdir($keyStorageRoot . '/' . $uid);
return true;
}

return false;
}
}

/**
* construct path to users key
*
Expand Down
10 changes: 10 additions & 0 deletions lib/public/Encryption/Keys/IStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,14 @@ public function renameKeys($source, $target);
*/
public function copyKeys($source, $target);

/**
* delete user keys from alternate storage location when
* a user is deleted
*
* @param $uid
* @return boolean
* @since 10.0.4
*/
public function deleteAltUserStorageKeys($uid);

}

0 comments on commit e05d242

Please sign in to comment.