From 6beeb2466f08dbed95f69761668efa6d27fc4d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 26 Mar 2013 16:17:26 +0100 Subject: [PATCH] also delete share keys if a different user than the owner deletes a shared file --- apps/files_encryption/lib/keymanager.php | 6 +----- apps/files_encryption/lib/proxy.php | 17 +++++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 9022ed2cac..49c6ffa8a5 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -363,11 +363,7 @@ class Keymanager { \OC_FileProxy::$enabled = false; - $util = new Util( $view, $userId ); - - list($owner, $filename) = $util->getUidAndFilename($filePath); - - $shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename; + $shareKeyPath = '/' . $userId . '/files_encryption/share-keys/' . $filePath; $absPath = $view->getLocalFile($shareKeyPath); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 7c981d4fc4..7c23336b3d 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -291,17 +291,22 @@ class Proxy extends \OC_FileProxy { \OC_FileProxy::$enabled = false; $view = new \OC_FilesystemView( '/' ); - + $userId = \OCP\USER::getUser(); - + + $util = new Util( $view, $userId ); + // Format path to be relative to user files dir $trimmed = ltrim( $path, '/' ); $split = explode( '/', $trimmed ); $sliced = array_slice( $split, 2 ); $relPath = implode( '/', $sliced ); - $filePath = $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $relPath; + + list($owner, $ownerPath) = $util->getUidAndFilename($relPath); + + $filePath = $owner . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $ownerPath; - if ( $view->is_dir( $path ) ) { + if ( $view->is_dir( $ownerPath ) ) { // Dirs must be handled separately as deleteFileKey // doesn't handle them @@ -312,8 +317,8 @@ class Proxy extends \OC_FileProxy { // Delete keyfile & shareKey so it isn't orphaned if ( ! ( - Keymanager::deleteFileKey( $view, $userId, $relPath ) - && Keymanager::delShareKey( $view, $userId, $relPath ) + Keymanager::deleteFileKey( $view, $owner, $ownerPath ) + && Keymanager::delShareKey( $view, $owner, $ownerPath ) ) ) {