Skip to content

WebDAV file copy broken when encryption is enabled #6705

Closed

Description

@PVince81

Expected behaviour

copy the file from one folder to another via webdav

Actual behaviour

without Encryption: files can be copied and can also be opened or renamed
with Encryption: the copy can not be opened with a local text editor, and in the browser, it looks like an "encoding error"

Steps to reproduce

  1. upload a text file "test.txt" with browser
  2. open the owncloud server with a webdav client
  3. create a subdirectory "subdir"
  4. using webdav, copy the text file into "subdir"
  5. open the copy with the local text editor, eg. gedit
  6. open the copy with text editor app in the browser

Server configuration

Operating system: ubuntu 12.04

Web server: apache 2.2

Database: SQLite

PHP version: 5.4.6

ownCloud version: 6.0.0a

Updated from an older ownCloud or fresh install: no

List of activated app:standard apps of owncloud 6.0.0a and encryption

The content of config/config.php: (Without the database password and passwordsalt)
CONFIG = array (
'instanceid' => 'oc0feadd60d8',

'datadirectory' => '/var/www/owncloud6/data',
'dbtype' => 'sqlite3',
'version' => '6.0.0.14',
'installed' => true,
'maxZipInputSize' => 17179869184,
'allowZipDownload' => true,

Are you using external storage, if yes which one: no

Client configuration

Browser: firefox 26.0

Operating system: ubuntu 12.04

WebDAV client: File manager from ubuntu

More information

I've debugged a bit and it seems the encryption app has no hooks related to file copy.
Note that this only happens for the WebDAV "COPY" operation which, AFAIK, is used neither by the sync client nor the web UI.
This would only affect users with WebDAV clients.

Activity

  1. PVince81 commented on Jan 9, 2014

    @PVince81
    ContributorAuthor

    FYI @schiesbn

    The code does a simple file copy and the target file is actually the encrypted version of the original file.
    Maybe the encryption app should have a hook and override the default file copy behavior somehow.
    Doing a stream copy instead of a file copy might work as well if it goes through the file proxies that decrypt and reencrypt the file.

    Also, I believe that the encryption key for the target file also need to be generated.

  2. karlitschek commented on Feb 18, 2014

    @karlitschek
    Contributor

    @schiesbn What do you think?

  3. PVince81 commented on Feb 24, 2014

    @PVince81
    ContributorAuthor

    Just discovered that there is a view->copy() operation that does a stream copy.
    Maybe that one isn't used correctly by the WebDAV connector.
    Needs further research.

  4. PVince81 commented on Feb 24, 2014

    @PVince81
    ContributorAuthor

    It seems the stream copy code isn't used because they are on the same mount point: https://github.com/owncloud/core/blob/master/lib/private/files/view.php#L536

    So two possible ways to fix this:

    1. Write a copy hook in encryption app to prepare/catch this case, not sure how this could interact with the storage->copy() that happens later though

    or

    1. Change the "if" condition to check whether encryption is enabled. If enabled, then always go to the "else" to use stream copy.
  5. schiessle commented on Feb 24, 2014

    @schiessle
    Contributor

    I'm not sure if the file needs to go through the stream wrapper. If the file is already encrypted we can just make a 1:1 copy, no need to decrypt it and encrypt it again.

    Maybe that's also part of the problem, if we don't skip the proxies here it could happen that after the copy operation the file is encrypted twice... Just an idea.

  6. PVince81 commented on Feb 24, 2014

    @PVince81
    ContributorAuthor

    I see, so we could copy the file there but also need to copy the key as well into the new dir, right ? That could happen in the "post copy" hook that isn't implemented yet in the encryption app.

  7. schiessle commented on Jul 30, 2014

    @schiessle
    Contributor

    fixed in master and stable7 (OC7.0.1)

  8. locked as resolved and limited conversation to collaborators on Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions