Skip to content

Fix error logs due to deletion of keys#28899

Merged
PVince81 merged 1 commit intomasterfrom
fix-errorlogs-encryptionwrapper-trashbin
Sep 6, 2017
Merged

Fix error logs due to deletion of keys#28899
PVince81 merged 1 commit intomasterfrom
fix-errorlogs-encryptionwrapper-trashbin

Conversation

@sharidas
Copy link
Contributor

@sharidas sharidas commented Sep 4, 2017

When files are deleted and moved to trashbin,
the keys are deleted. This results in exception
due to file not exist. And hence this change
helps to fix the issue. The issue is caused
when the version of the files are tried to
retain in the trashbin.

Signed-off-by: Sujith H sharidasan@owncloud.com

Description

When the files are moved to trashbin, the retain version causes problem. Which means the retainVersion in the trashbin tries to access the file keys which are already deleted. So this causes exception.

Related Issue

#28883

Motivation and Context

This change tries to solve the issue caused by accessing file keys which are already deleted during the transfer of files to trashbin.

How Has This Been Tested?

  • Enable encryption with master key
  • Enable external sotrage with SFTP
  • Upload a file to SFTP folder
  • Update the file.
  • Delete the file . The log file is clean and no exceptions.
  • Restore the file. The log file is clean and no exceptions.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sharidas sharidas added this to the development milestone Sep 4, 2017
@sharidas sharidas self-assigned this Sep 4, 2017
@sharidas sharidas force-pushed the fix-errorlogs-encryptionwrapper-trashbin branch 2 times, most recently from 83841b7 to c93784c Compare September 4, 2017 12:17
@sharidas sharidas requested a review from PVince81 September 4, 2017 12:31
@sharidas sharidas changed the title Fix error logs due to deletion of keys [WIP] Fix error logs due to deletion of keys Sep 4, 2017
@sharidas sharidas changed the title [WIP] Fix error logs due to deletion of keys Fix error logs due to deletion of keys Sep 5, 2017
self::copy_recursive($source, $target, $view);

self::retainVersions($targetFilename, $owner, $ownerPath, $timestamp, true);
self::retainVersions($targetFilename, $owner, $ownerPath, $timestamp, false,true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing space after ","

* @param bool $forceCopy true to only make a copy of the versions into the trashbin
*/
private static function retainVersions($filename, $owner, $ownerPath, $timestamp, $forceCopy = false) {
private static function retainVersions($filename, $owner, $ownerPath, $timestamp, $sourceStorage= false, $forceCopy = false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use null instead of false ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and there is missing space between $sourceStorage and =


$copyKeysResult = false;

if (\OC::$server->getEncryptionManager()->isEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see, in the past we never had encryption code directly in the trashbin.

There must be logic elsewhere already about moving/copying encryption keys to trash, it is likely that this logic exists directly in the encryption app. Can you find it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharidas sharidas force-pushed the fix-errorlogs-encryptionwrapper-trashbin branch 3 times, most recently from f80efd1 to 45ab3ec Compare September 5, 2017 11:22
When files are deleted and moved to trashbin,
the keys are deleted. This results in exception
due to file not exist. And hence this change
helps to fix the issue. The issue is caused
when the version of the files are tried to
retain in the trashbin.

Signed-off-by: Sujith H <sharidasan@owncloud.com>
@sharidas sharidas force-pushed the fix-errorlogs-encryptionwrapper-trashbin branch from 45ab3ec to 11338d3 Compare September 5, 2017 16:26
@PVince81
Copy link
Contributor

PVince81 commented Sep 6, 2017

Can you make sure the following still works correctly:

  • single storage: deleted encrypted file with versions restored: file and versions can be downloaded fine
  • cross-storage: deleted encrypted file with versions restored: file and versions can be downloaded fine

I see your test steps above but they don't seem to cover checking that the restored versions still work.

@sharidas
Copy link
Contributor Author

sharidas commented Sep 6, 2017

@PVince81 Below are the tests done

Single Storage

  • Enable encryption

  • Upload a file foo.txt

  • Rename the file foo.txt to Test.txt

  • Update the file by adding a line "Version 1 ..."
    beforedeletion

  • Verify that 2 versions of the file are there from UI

  • Delete the file
    deleted

  • Restore the file

  • Verified the 2 versions of the file are there..
    afterrestore

  • Repeated the above steps to create one more version and the restore was successfully done. The 3 versions were available after restore.

  • Verified from the terminal after the download.
    terminalverification

Cross Storage

  • Enable encryption

  • Enable external storage with SFTP

  • Upload a file to SFTP folder

  • Update the file by adding line "Version 1 ..."
    versionupdatebeforedeletion

  • Verify the version from UI.

  • Delete the file
    filedeleted

  • Restore the file

  • Verify the versions in the UI ( 2 versions )
    filerestoreanddownloaded

  • Repeat the steps for 3rd Version.

  • Verified the versions downloaded in the terminal.
    terminalverification

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PVince81 PVince81 merged commit d21e601 into master Sep 6, 2017
@PVince81 PVince81 deleted the fix-errorlogs-encryptionwrapper-trashbin branch September 6, 2017 16:28
@PVince81
Copy link
Contributor

PVince81 commented Sep 6, 2017

Please backport to stable10, set milestone to "planned" for the next release there

@sharidas
Copy link
Contributor Author

sharidas commented Sep 7, 2017

Back port PR: #28934

@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants