Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix creation of versions of encrypted files on external storages #23675

Merged
merged 1 commit into from
Mar 31, 2016

Conversation

schiessle
Copy link
Contributor

in order to create a 1:1 copy of a file if a version gets created we need to store this information on copyBetweenStorage(). This allows us to by-pass the encryption wrapper if we read the source file.

@karlitschek we should consider to backport it to 9.0, 8.2 and 8.1. At the moment versions of files on external storages are stored unencrypted!

  • adjust and add unit tests

cc @PVince81 @LukasReschke please have a look... Thanks!

@karlitschek
Copy link
Contributor

backport is fine if reviewed successfully by others 👍

@@ -301,6 +305,9 @@ public function __construct($webRoot, \OC\Config $config) {
'\\OC\\Memcache\\ArrayCache'
);
});
$this->registerService('ArrayCache', function(Server $c) {
return new ArrayCache();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should be global at this level. If other apps use it, there will be key name conflicts.

If you still think it should be that way, then please use prefixes for the key names you use.

@icewind1991 what do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

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

its fine here, on usage a sane prefix should be used

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the reason for a global ArrayCache in the server container

Copy link
Contributor

Choose a reason for hiding this comment

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

We need the same instance all the time

Copy link
Contributor

Choose a reason for hiding this comment

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

There is only one encryption manager right, so that would pass one instance of the cache to all wrappers it's creates

Copy link
Contributor

Choose a reason for hiding this comment

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

Well it's the util class that wraps, and that one also is generated new each time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @icewind1991, we should find a way to this ArrayCache global only for the encryption code, not OC-wide global. If this was in the encryption app, we could have it in the encryption app's container.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is in core, not in the encryption app, but @schiesbn is trying to do it nicely anyway

@PVince81
Copy link
Contributor

Setting to critical since the bug breaks versions with encryption + ext storage (data loss)

@PVince81 PVince81 added this to the 9.1-current milestone Mar 31, 2016
@PVince81
Copy link
Contributor

Fixes #23681

@schiessle schiessle force-pushed the fix_encryption_versions_on_external_storages branch 2 times, most recently from 3540868 to c46643e Compare March 31, 2016 10:11
@schiessle
Copy link
Contributor Author

I removed the global array cache, this increased the size of the PR a bit but I tried to keep the changes as small as possible.

use OCP\Files\Storage;
use OCP\ILogger;

class EncryptionWrapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a note that this is not the actuall wrapper but the thing that applies the wrapper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point... done.

@PVince81
Copy link
Contributor

@schiesbn thank you, the code looks much better!

Doesn't work though, when I overwrite more than once (with Webdav), it seems the next versions get broken:
sftp-enc-versions

@schiessle
Copy link
Contributor Author

@PVince81 I can't reproduce it with sftp, maybe a independent webdav external storage issue?

@davitol
Copy link
Contributor

davitol commented Mar 31, 2016

@PVince81 @schiesbn As Vincent said, it only works for the 1st version of the file. The following via webdavversions are broken for me too. I used SFTP as external storage

screen shot 2016-03-31 at 12 28 30

@schiessle schiessle force-pushed the fix_encryption_versions_on_external_storages branch from c46643e to f5e5195 Compare March 31, 2016 10:30
@PVince81
Copy link
Contributor

@schiesbn my test was with SFTP. If you can't reproduce we can debug it on my machine later.

@PVince81
Copy link
Contributor

My steps:

  1. Setup OC from scratch
  2. Enable encryption, log out, log in again
  3. Enable external storage app
  4. Mount SFTP as "/sftp" (the remote folder is completely empty)
  5. Start cadaver
  6. mkdir /sftp/enc
  7. `cd enc'
  8. Download https://s3.owncloud.com/owncloud/index.php/s/w6x2yXIxOqqYjhy/download and put it in a local folder for uploading with cadaver
  9. cadaver: put bacon.txt three times
  10. Go to the web UI, open the versions dropdown
  11. Download the file that has a broken thumbnail

Make sure to NOT use the web UI until the end to not pre-generate previews, in case it matters.

@schiessle
Copy link
Contributor Author

I always tested it with small text files, updating it with the text editor. I remember @LukasReschke said yesterday that we also need the RetryWrapper for sftp. Maybe that's the issue if you test it with larger files? @LukasReschke do you already prepared a pull request for it?

@PVince81
Copy link
Contributor

@schiesbn #23672 was merged, please rebase onto master so we get it

@PVince81
Copy link
Contributor

Same result with RetryWrapper on SFTP 😦

@schiessle
Copy link
Contributor Author

I think that's a different issue. If I try it with large files not only some versions are broken but also the original file after some updates "Bad Signature"...

@schiessle
Copy link
Contributor Author

... if you check the versions on the hard disc all versions should be encrypted. That's what is fixed by this issue. We need to investigate other issues independently

@PVince81
Copy link
Contributor

@schiesbn the version files on-disk are indeed encrypted properly. Fine by me, I'll make a separate issue for it.

@PVince81
Copy link
Contributor

👍 fixes the "unencrypted versions" creation bug

@schiessle
Copy link
Contributor Author

If I look at the file cache the 'encryption' is set for all files (original and all versions) to '1' which is of course wrong.

@LukasReschke
Copy link
Member

@PVince81 @schiesbn As Vincent said, it only works for the 1st version of the file. The following via webdavversions are broken for me too. I used SFTP as external storage

@davitol Can you retest this including #23707?

@@ -61,13 +62,14 @@ class Manager implements IManager {
* @param View $rootView
* @param Util $util
*/
public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util) {
public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) {
Copy link
Member

Choose a reason for hiding this comment

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

PHPDoc missing

@LukasReschke
Copy link
Member

Code works fine. Can you adjust my remarks? Thanks a lot 🚀 👍

in order to create a 1:1 copy of a file if a version gets created
we need to store this information on copyBetweenStorage(). This
allows us to by-pass the encryption wrapper if we read the source file.
@schiessle schiessle force-pushed the fix_encryption_versions_on_external_storages branch from f5e5195 to 93ed965 Compare March 31, 2016 17:25
@schiessle
Copy link
Contributor Author

addressed @LukasReschke comments.

@PVince81
Copy link
Contributor

@karlitschek many code changes, please reconfirm backport

@karlitschek
Copy link
Contributor

backport is fine 👍

@schiessle
Copy link
Contributor Author

stable 9.0: #23710
stable 8.2: #23711
stable 8.1: no backport, code base differs to much

@lock
Copy link

lock bot commented Aug 6, 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 6, 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.

9 participants