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

moving a locked file overwriting an other locked files moves the lock from source to destination file #34387

Open
individual-it opened this issue Feb 5, 2019 · 2 comments

Comments

@individual-it
Copy link
Member

Steps to reproduce

  1. lock "textfile1.txt" and "textfile2.txt"
    curl -u uu1:uu1 -X LOCK "http://localhost/owncloud-core/remote.php/dav/files/uu1/textfile1.txt" -d "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><d:exclusive/></d:lockscope><d:owner>lock fom textfile1</d:owner></d:lockinfo>" | xmllint --format -
      <d:locktoken>
        <d:href>opaquelocktoken:f900492b-47b3-4f69-9374-9dc2c3a8779f</d:href>
      </d:locktoken>
      <d:owner>lock fom textfile1</d:owner>

curl -u uu1:uu1 -X LOCK "http://localhost/owncloud-core/remote.php/dav/files/uu1/textfile2.txt" -d "<?xml version='1.0' encoding='UTF-8'?><d:lockinfo xmlns:d='DAV:'> <d:lockscope><d:exclusive/></d:lockscope><d:owner>lock fom textfile2</d:owner></d:lockinfo>" | xmllint --format -

      <d:locktoken>
        <d:href>opaquelocktoken:95ece69c-fa1e-4faf-9c6b-8c103981d2ed</d:href>
      </d:locktoken>
      <d:owner>lock fom textfile2</d:owner>
  1. move "textfile2.txt" to "textfile1.txt" by supplying both tokens
    curl -u uu1:uu1 -X MOVE "http://localhost/owncloud-core/remote.php/dav/files/uu1/textfile2.txt" -H "Destination: http://localhost/owncloud-core/remote.php/dav/files/uu1/textfile1.txt" -H "If: (<opaquelocktoken:95ece69c-fa1e-4faf-9c6b-8c103981d2ed>) (<opaquelocktoken:f900492b-47b3-4f69-9374-9dc2c3a8779f>)"
  2. check the lock on "textfile1.txt"
    curl -u uu1:uu1 -X PROPFIND http://localhost/owncloud-core/remote.php/webdav/textfile1.txt -d "<?xml version='1.0' encoding='UTF-8'?> <d:propfind xmlns:d='DAV:'> <d:prop><d:lockdiscovery/></d:prop> </d:propfind>" | xmllint --format -

Expected behaviour

token of "textfile1.txt" is preserved
https://tools.ietf.org/html/rfc4918#section-7.6:

A successful MOVE request on a write locked resource MUST NOT move
the write lock with the resource. However, if there is an existing
lock at the destination, the server MUST add the moved resource to
the destination lock scope.

Actual behaviour

            <d:locktoken>
              <d:href>opaquelocktoken:95ece69c-fa1e-4faf-9c6b-8c103981d2ed</d:href>
            </d:locktoken>
            <d:owner>lock fom textfile2</d:owner>
          </d:activelock>
@ownclouders
Copy link
Contributor

GitMate.io thinks possibly related issues are #24737 (File Locked), #26838 (File locking), #17098 (Unexpected locked exception overwriting a file), #34386 (copying a file on a locked file removes the lock on the destination), and #32032 (Let files be overwritten).

@PVince81
Copy link
Contributor

PVince81 commented Feb 5, 2019

this happens because our locks are based on the file id.

when overwriting a file, I think we preserve the file id of the destination so the destination's lock is the one that stays.

to fix this we'll need to detect moves in our Sabre plugin and tell the LockManager to remove the target lock and move the old lock to the new one.

@PVince81 PVince81 added the p3-medium Normal priority label Feb 5, 2019
@PVince81 PVince81 modified the milestones: QA, backlog Feb 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants