]> source.dussan.org Git - nextcloud-server.git/commitdiff
Deleting encrypted files with missing keyfiles/shareKeys now succeeds
authorSam Tuke <samtuke@owncloud.com>
Wed, 27 Feb 2013 16:15:03 +0000 (16:15 +0000)
committerSam Tuke <samtuke@owncloud.com>
Wed, 27 Feb 2013 16:15:03 +0000 (16:15 +0000)
apps/files_encryption/hooks/hooks.php
apps/files_encryption/lib/crypt.php
apps/files_encryption/lib/proxy.php
apps/files_encryption/lib/util.php

index fb3545208d21078e511eb9e2b71159ab45e3772e..590ba7b1b97ece5fd2f563fa823340a9e32b92a4 100644 (file)
@@ -279,13 +279,8 @@ class Hooks {
         */\r
        public static function postUnshareAll( $params ) {\r
        \r
-//             $view = new \OC_FilesystemView( '/' );\r
-//             $session = new Session();\r
-//             $userId = \OCP\User::getUser();\r
-//             $util = new Util( $view, $userId );\r
-//             $path = $util->fileIdToPath( $params['itemSource'] );\r
-//             \r
-//             return Crypt::updateKeyfile( $view, $util, $session, $userId, $path );\r
+               // NOTE: It appears that this is never called for files, so \r
+               // we may not need to implement it\r
                \r
        }\r
        \r
index 5a2d99df5460dac7337f953a83d26d6453aec4d4..a138f5f3cb09a089cc11128370bd86b0c2b87ee8 100755 (executable)
@@ -390,8 +390,6 @@ class Crypt {
                $shareKeys = array();\r
        \r
                if( openssl_seal( $plainContent, $sealed, $shareKeys, $publicKeys ) ) {\r
-               \r
-//                     trigger_error("SEALED = $sealed");\r
                        \r
                        $i = 0;\r
                        \r
index 29207dce07d6d178e996a575567ad07c73390fda..92a70499367d167abc8532c3dad66eef0a82163b 100644 (file)
@@ -272,23 +272,38 @@ class Proxy extends \OC_FileProxy {
                $split = explode( '/', $trimmed );
                $sliced = array_slice( $split, 2 );
                $relPath = implode( '/', $sliced );
+               $filePath = $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $relPath;
                
                if ( $view->is_dir( $path ) ) {
                        
                        // Dirs must be handled separately as deleteFileKey 
                        // doesn't handle them
-                       $view->unlink( $userId . '/' . 'files_encryption' . '/' . 'keyfiles' . '/'. $relPath );
+                       $view->unlink( $filePath );
                        
                } else {
                
-                       // Delete keyfile so it isn't orphaned
-                       $result = Keymanager::deleteFileKey( $view, $userId, $relPath );
-               
-                       \OC_FileProxy::$enabled = true;
+                       // Delete keyfile & shareKey so it isn't orphaned
+                       if (
+                               ! ( 
+                                       Keymanager::deleteFileKey( $view, $userId, $relPath )
+                                       && Keymanager::delShareKey( $view, $userId, $relPath ) 
+                               )
+                       ) {
+                       
+                               \OC_Log::write( 'Encryption library', 'Keyfile or shareKey could not be deleted for file "'.$filePath.'"', \OC_Log::ERROR );
+                               
+                               
+                       }
+                       
                        
-                       return $result;
                
                }
+               
+               \OC_FileProxy::$enabled = true;
+               
+               // If we don't return true then file delete will fail; better
+               // to leave orphaned keyfiles than to disallow file deletion
+               return true;
        
        }
 
index 02c62e160c8cea7daf41ec6112ef51f67f6bdf8e..31ce3a413cc469e712b69ed2a0f3eb3b0ee8df4a 100644 (file)
 # Bugs
 # ----
 # Sharing a file to a user without encryption set up will not provide them with access but won't notify the sharer
-# Deleting files if keyfile is missing fails
 # When encryption app is disabled files become unreadable
 # Timeouts on first login due to encryption of very large files
-# MultiKeyEncrypt() may be failing
 
 
 # Missing features
 # ----------------
-# Unshare a file
 # Re-use existing keyfiles so they don't need version control
 # Make sure user knows if large files weren't encrypted
 # Trashbin support