fix file sharing, sharing files works now; moved the identification of file owner and the owner path in the keymanager functions so that other functions doesn't have to deal with it
This commit is contained in:
parent
7892fddcb9
commit
40905c8941
|
@ -108,10 +108,12 @@ class Keymanager {
|
|||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
\OC\Files\Filesystem::initMountPoints($userId);
|
||||
$basePath = '/' . $userId . '/files_encryption/keyfiles';
|
||||
$util = new Util($view, $userId);
|
||||
list($owner, $filename) = $util->getUidAndFilename($path);
|
||||
|
||||
$targetPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
||||
$basePath = '/' . $owner . '/files_encryption/keyfiles';
|
||||
|
||||
$targetPath = self::keySetPreparation( $view, $filename, $basePath, $owner );
|
||||
|
||||
if ( !$view->is_dir( $basePath . '/' . $targetPath ) ) {
|
||||
|
||||
|
@ -166,10 +168,11 @@ class Keymanager {
|
|||
*/
|
||||
public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||
|
||||
\OC\Files\Filesystem::initMountPoints($userId);
|
||||
$filePath_f = ltrim( $filePath, '/' );
|
||||
$util = new Util($view, $userId);
|
||||
list($owner, $filename) = $util->getUidAndFilename($filePath);
|
||||
$filePath_f = ltrim( $filename, '/' );
|
||||
|
||||
$keyfilePath = '/' . $userId . '/files_encryption/keyfiles/' . $filePath_f . '.key';
|
||||
$keyfilePath = '/' . $owner . '/files_encryption/keyfiles/' . $filePath_f . '.key';
|
||||
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ class Proxy extends \OC_FileProxy {
|
|||
$rootView = new \OC_FilesystemView( '/' );
|
||||
$util = new Util( $rootView, $userId );
|
||||
$session = new Session( $rootView );
|
||||
$fileOwner = \OC\Files\Filesystem::getOwner( $path );
|
||||
$privateKey = $session->getPrivateKey();
|
||||
$filePath = $util->stripUserFilesPath( $path );
|
||||
// Set the filesize for userland, before encrypting
|
||||
|
@ -112,7 +111,7 @@ class Proxy extends \OC_FileProxy {
|
|||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
// Check if there is an existing key we can reuse
|
||||
if ( $encKeyfile = Keymanager::getFileKey( $rootView, $fileOwner, $filePath ) ) {
|
||||
if ( $encKeyfile = Keymanager::getFileKey( $rootView, $userId, $filePath ) ) {
|
||||
|
||||
// Fetch shareKey
|
||||
$shareKey = Keymanager::getShareKey( $rootView, $userId, $filePath );
|
||||
|
@ -153,7 +152,7 @@ class Proxy extends \OC_FileProxy {
|
|||
$encKey = $multiEncrypted['data'];
|
||||
|
||||
// Save keyfile for newly encrypted file in parallel directory tree
|
||||
Keymanager::setFileKey( $rootView, $filePath, $fileOwner, $encKey );
|
||||
Keymanager::setFileKey( $rootView, $filePath, $userId, $encKey );
|
||||
|
||||
// Replace plain content with encrypted content by reference
|
||||
$data = $encData;
|
||||
|
@ -198,14 +197,8 @@ class Proxy extends \OC_FileProxy {
|
|||
$session = new Session( $view );
|
||||
$privateKey = $session->getPrivateKey( $userId );
|
||||
|
||||
// Get the file owner so we can retrieve its keyfile
|
||||
// list( $fileOwner, $ownerPath ) = $util->getUidAndFilename( $relPath );
|
||||
|
||||
$fileOwner = \OC\Files\Filesystem::getOwner( $path );
|
||||
$ownerPath = $util->stripUserFilesPath( $path ); // TODO: Don't trust $path, fetch owner path
|
||||
|
||||
// Get the encrypted keyfile
|
||||
$encKeyfile = Keymanager::getFileKey( $view, $fileOwner, $ownerPath );
|
||||
$encKeyfile = Keymanager::getFileKey( $view, $userId, $relPath );
|
||||
|
||||
// Attempt to fetch the user's shareKey
|
||||
$shareKey = Keymanager::getShareKey( $view, $userId, $relPath );
|
||||
|
|
Loading…
Reference in New Issue