Skip to content

don't encrypt if the target is a mounted ownCloud - #13156

Closed
schiessle wants to merge 1 commit into
masterfrom
exclude_owncloud_mount_from_enc
Closed

schiessle wants to merge 1 commit into
masterfrom
exclude_owncloud_mount_from_enc

Conversation

@schiessle

Copy link
Copy Markdown
Contributor

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@LukasReschke

Copy link
Copy Markdown
Contributor

Requires documentation adjustment then.

@carlaschroder

@karlitschek

Copy link
Copy Markdown
Contributor

looks good 👍

@DeepDiver1975

Copy link
Copy Markdown
Contributor

as discussed 👍

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

Tested, works 👍

The cool thing is that you can also mount an OC 7 instance as this fix is on the mounting instance.

@karlitschek do we want to backport this ? If yes, it will make it possible to mount OC 8 inside OC 7 as well.

@PVince81 PVince81 added this to the 8.0-current milestone Jan 7, 2015
@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

Please hold. I'm testing with the sync client and am experiencing issues. (expected filesize X got Y)
The issues might not be related directly, but maybe additional fixing might be required for the sync client to work properly.

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

The size values are always the same, possibly a mix up between encrypted size and unencrypted size.

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor
{"reqId":"0c5ff80c2e360197d86bffc30decaa8e","remoteAddr":"127.0.0.1","app":"webdav","message":"Exception: {\"Message\":\"expected filesize 2204330 got 2955940\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/directory.php(84): OC_Connector_Sabre_File->put(Resource id #407)\\n#1 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(1647): OC_Connector_Sabre_Directory->createFile('P1070118.JPG', Resource id #407)\\n#2 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(900): Sabre\\\\DAV\\\\Server->createFile('remote\\\/P1070118...', Resource id #407, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\Server->httpPut('remote\\\/P1070118...')\\n#4 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(474): call_user_func(Array, 'remote\\\/P1070118...')\\n#5 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(214): Sabre\\\\DAV\\\\Server->invokeMethod('PUT', 'remote\\\/P1070118...')\\n#6 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/apps\\\/files\\\/appinfo\\\/remote.php(61): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/remote.php(54): require_once('\\\/srv\\\/www\\\/htdocs...')\\n#8 {main}\",\"File\":\"\\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/file.php\",\"Line\":122}","level":4,"time":"2015-01-07T16:48:18+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/remote\/P1070118.JPG"}
{"reqId":"15df770904fad7d911447d9194008b7e","remoteAddr":"127.0.0.1","app":"webdav","message":"Exception: {\"Message\":\"expected filesize 3016898 got 4042556\",\"Code\":0,\"Trace\":\"#0 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/directory.php(84): OC_Connector_Sabre_File->put(Resource id #407)\\n#1 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(1647): OC_Connector_Sabre_Directory->createFile('P1070103.JPG', Resource id #407)\\n#2 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(900): Sabre\\\\DAV\\\\Server->createFile('remote\\\/P1070103...', Resource id #407, NULL)\\n#3 [internal function]: Sabre\\\\DAV\\\\Server->httpPut('remote\\\/P1070103...')\\n#4 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(474): call_user_func(Array, 'remote\\\/P1070103...')\\n#5 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/Sabre\\\/DAV\\\/Server.php(214): Sabre\\\\DAV\\\\Server->invokeMethod('PUT', 'remote\\\/P1070103...')\\n#6 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/apps\\\/files\\\/appinfo\\\/remote.php(61): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/remote.php(54): require_once('\\\/srv\\\/www\\\/htdocs...')\\n#8 {main}\",\"File\":\"\\\/srv\\\/www\\\/htdocs\\\/owncloud\\\/lib\\\/private\\\/connector\\\/sabre\\\/file.php\",\"Line\":122}","level":4,"time":"2015-01-07T16:48:18+00:00","method":"PUT","url":"\/owncloud\/remote.php\/webdav\/remote\/P1070103.JPG"}

Ouch, I think I got it. Tricky stuff.

I have two OC instances: OC A and OC B, both encrypted.
OC A mounts OC B.
When a file is sent to OC B for upload, the file itself is sent unencrypted.
But the resulting part file that appears on OC B is encrypted.
So when querying the filesize of the part file, the encrypted size is returned. Since the part file is not in the database, it has no "unencrypted_size" value, so I suppose that in this case OC B will just read the file size itself.

This will need an additional fix, might be tricky.

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

For now 👎 don't merge yet

@ghost

ghost commented Jan 7, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/6005/
👍 Test PASSed. 👍

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

After a long discussion with @schiesbn and examining multiple solutions, the best fix we found is as follows:

  1. frontend OC checks whether ext storage is of type OC
  2. if yes, OC sends the assembled file directly (strip off the ".part" prefix) and do not rename the file.
    This is because the backend OC already uses a part file itself. So there is no need for the frontend OC to also have the "upload part file then rename" logic.

This removes the bogus case where we try and do file operations remotely on a remote part file (the filesize case)

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

I tested this locally by manually stripping the ".part" (and ocTransferID) in the frontend OC and it worked fine.
Next step is to implement this properly.
For OC 8.0: add a test of instanceof for the storage. If it's server to server sharing or owncloud backend, then skip the part file case.
For OC 8.1+: add a method "needPartFile()" on the Storage interface that returns false for the OwnCloud backend.
For OC 8.x+: use the chunk/part handler logic to disable it for the ownCloud backend.

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

CC @icewind1991 for additional input

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

The problem I found also happens with server to server sharing on master and stable7, documented here #13157

@PVince81

PVince81 commented Jan 7, 2015

Copy link
Copy Markdown
Contributor

Obsoleted by #13160.

Note that this PR here would prevent encrypting files when sending them to the target OC storage. But the linked PR above would keep encryption. I think it is better to keep encryption now for consistency.
In the future the user will be able to choose whether to enable encryption for specific storages. So based on the use case whether the remote OC is trusted or not, it will be the user's choice the encrypt the files sent to that OC. Will be addressed separately: see #10731

@PVince81 PVince81 closed this Jan 7, 2015
@schiessle
schiessle deleted the exclude_owncloud_mount_from_enc branch January 8, 2015 09:22
@carlaschroder

Copy link
Copy Markdown

Oh help. Does this still need to be documented, and WTH do I say?
@LukasReschke
@PVince81

@PVince81

Copy link
Copy Markdown
Contributor

@carlaschroder forget this one. We used another approach that does not disable encryption.
So, nothing to do.

@carlaschroder

Copy link
Copy Markdown

thanks @PVince81

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ownCloud external storage mount doesn't work with encryption

7 participants