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
|
@ -107,11 +107,13 @@ class Keymanager {
|
||||||
public static function setFileKey( \OC_FilesystemView $view, $path, $userId, $catfile ) {
|
public static function setFileKey( \OC_FilesystemView $view, $path, $userId, $catfile ) {
|
||||||
|
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
|
$util = new Util($view, $userId);
|
||||||
|
list($owner, $filename) = $util->getUidAndFilename($path);
|
||||||
|
|
||||||
|
$basePath = '/' . $owner . '/files_encryption/keyfiles';
|
||||||
|
|
||||||
\OC\Files\Filesystem::initMountPoints($userId);
|
$targetPath = self::keySetPreparation( $view, $filename, $basePath, $owner );
|
||||||
$basePath = '/' . $userId . '/files_encryption/keyfiles';
|
|
||||||
|
|
||||||
$targetPath = self::keySetPreparation( $view, $path, $basePath, $userId );
|
|
||||||
|
|
||||||
if ( !$view->is_dir( $basePath . '/' . $targetPath ) ) {
|
if ( !$view->is_dir( $basePath . '/' . $targetPath ) ) {
|
||||||
|
|
||||||
|
@ -166,10 +168,11 @@ class Keymanager {
|
||||||
*/
|
*/
|
||||||
public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
|
public static function getFileKey( \OC_FilesystemView $view, $userId, $filePath ) {
|
||||||
|
|
||||||
\OC\Files\Filesystem::initMountPoints($userId);
|
$util = new Util($view, $userId);
|
||||||
$filePath_f = ltrim( $filePath, '/' );
|
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;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,6 @@ class Proxy extends \OC_FileProxy {
|
||||||
$rootView = new \OC_FilesystemView( '/' );
|
$rootView = new \OC_FilesystemView( '/' );
|
||||||
$util = new Util( $rootView, $userId );
|
$util = new Util( $rootView, $userId );
|
||||||
$session = new Session( $rootView );
|
$session = new Session( $rootView );
|
||||||
$fileOwner = \OC\Files\Filesystem::getOwner( $path );
|
|
||||||
$privateKey = $session->getPrivateKey();
|
$privateKey = $session->getPrivateKey();
|
||||||
$filePath = $util->stripUserFilesPath( $path );
|
$filePath = $util->stripUserFilesPath( $path );
|
||||||
// Set the filesize for userland, before encrypting
|
// Set the filesize for userland, before encrypting
|
||||||
|
@ -112,7 +111,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
\OC_FileProxy::$enabled = false;
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
// Check if there is an existing key we can reuse
|
// 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
|
// Fetch shareKey
|
||||||
$shareKey = Keymanager::getShareKey( $rootView, $userId, $filePath );
|
$shareKey = Keymanager::getShareKey( $rootView, $userId, $filePath );
|
||||||
|
@ -153,7 +152,7 @@ class Proxy extends \OC_FileProxy {
|
||||||
$encKey = $multiEncrypted['data'];
|
$encKey = $multiEncrypted['data'];
|
||||||
|
|
||||||
// Save keyfile for newly encrypted file in parallel directory tree
|
// 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
|
// Replace plain content with encrypted content by reference
|
||||||
$data = $encData;
|
$data = $encData;
|
||||||
|
@ -198,14 +197,8 @@ class Proxy extends \OC_FileProxy {
|
||||||
$session = new Session( $view );
|
$session = new Session( $view );
|
||||||
$privateKey = $session->getPrivateKey( $userId );
|
$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
|
// Get the encrypted keyfile
|
||||||
$encKeyfile = Keymanager::getFileKey( $view, $fileOwner, $ownerPath );
|
$encKeyfile = Keymanager::getFileKey( $view, $userId, $relPath );
|
||||||
|
|
||||||
// Attempt to fetch the user's shareKey
|
// Attempt to fetch the user's shareKey
|
||||||
$shareKey = Keymanager::getShareKey( $view, $userId, $relPath );
|
$shareKey = Keymanager::getShareKey( $view, $userId, $relPath );
|
||||||
|
|
Loading…
Reference in New Issue