delete all share keys if a file gets deleted
This commit is contained in:
parent
b5cb5dab51
commit
a4364a93d0
|
@ -392,6 +392,25 @@ class Keymanager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief delete all share keys of a given file
|
||||||
|
* @param \OC_FilesystemView $view
|
||||||
|
* @param type $userId owner of the file
|
||||||
|
* @param type $filePath path to the file, relative to the owners file dir
|
||||||
|
*/
|
||||||
|
public static function delAllShareKeys(\OC_FilesystemView $view, $userId, $filePath) {
|
||||||
|
|
||||||
|
if ($view->is_dir($userId.'/files/'.$filePath)) {
|
||||||
|
$view->unlink($userId.'/files_encryption/share-keys/'.$filePath);
|
||||||
|
} else {
|
||||||
|
$localKeyPath = $view->getLocalFile($userId.'/files_encryption/share-keys/'.$filePath);
|
||||||
|
$matches = glob(preg_quote($localKeyPath).'*.shareKey');
|
||||||
|
foreach ($matches as $ma) {
|
||||||
|
unlink($ma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete a single user's shareKey for a single file
|
* @brief Delete a single user's shareKey for a single file
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -256,18 +256,13 @@ class Proxy extends \OC_FileProxy {
|
||||||
// Format path to be relative to user files dir
|
// Format path to be relative to user files dir
|
||||||
$relPath = $util->stripUserFilesPath( $path );
|
$relPath = $util->stripUserFilesPath( $path );
|
||||||
|
|
||||||
// list( $owner, $ownerPath ) = $util->getUidAndFilename( $relPath );
|
list( $owner, $ownerPath ) = $util->getUidAndFilename( $relPath );
|
||||||
|
|
||||||
$fileOwner = \OC\Files\Filesystem::getOwner( $path );
|
|
||||||
$ownerPath = $util->stripUserFilesPath( $path ); // TODO: Don't trust $path, fetch owner path
|
|
||||||
|
|
||||||
$filePath = $fileOwner . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $ownerPath;
|
|
||||||
|
|
||||||
// Delete keyfile & shareKey so it isn't orphaned
|
// Delete keyfile & shareKey so it isn't orphaned
|
||||||
if (
|
if (
|
||||||
! (
|
! (
|
||||||
Keymanager::deleteFileKey( $view, $fileOwner, $ownerPath )
|
Keymanager::deleteFileKey( $view, $owner, $ownerPath )
|
||||||
&& Keymanager::delShareKey( $view, $fileOwner, $ownerPath )
|
&& Keymanager::delAllShareKeys( $view, $owner, $ownerPath )
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue