also delete share keys if a different user than the owner deletes a shared file

This commit is contained in:
Björn Schießle 2013-03-26 16:17:26 +01:00
parent b1d620300e
commit 6beeb2466f
2 changed files with 12 additions and 11 deletions

View File

@ -363,11 +363,7 @@ class Keymanager {
\OC_FileProxy::$enabled = false; \OC_FileProxy::$enabled = false;
$util = new Util( $view, $userId ); $shareKeyPath = '/' . $userId . '/files_encryption/share-keys/' . $filePath;
list($owner, $filename) = $util->getUidAndFilename($filePath);
$shareKeyPath = '/' . $owner . '/files_encryption/share-keys/' . $filename;
$absPath = $view->getLocalFile($shareKeyPath); $absPath = $view->getLocalFile($shareKeyPath);

View File

@ -291,17 +291,22 @@ class Proxy extends \OC_FileProxy {
\OC_FileProxy::$enabled = false; \OC_FileProxy::$enabled = false;
$view = new \OC_FilesystemView( '/' ); $view = new \OC_FilesystemView( '/' );
$userId = \OCP\USER::getUser(); $userId = \OCP\USER::getUser();
$util = new Util( $view, $userId );
// Format path to be relative to user files dir // Format path to be relative to user files dir
$trimmed = ltrim( $path, '/' ); $trimmed = ltrim( $path, '/' );
$split = explode( '/', $trimmed ); $split = explode( '/', $trimmed );
$sliced = array_slice( $split, 2 ); $sliced = array_slice( $split, 2 );
$relPath = implode( '/', $sliced ); $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 // Dirs must be handled separately as deleteFileKey
// doesn't handle them // doesn't handle them
@ -312,8 +317,8 @@ class Proxy extends \OC_FileProxy {
// Delete keyfile & shareKey so it isn't orphaned // Delete keyfile & shareKey so it isn't orphaned
if ( if (
! ( ! (
Keymanager::deleteFileKey( $view, $userId, $relPath ) Keymanager::deleteFileKey( $view, $owner, $ownerPath )
&& Keymanager::delShareKey( $view, $userId, $relPath ) && Keymanager::delShareKey( $view, $owner, $ownerPath )
) )
) { ) {