Repository navigation
Protect the members of a collection with a depth 0 WebDAV lock - #1258
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
A depth 0 write lock on a collection did not prevent other clients from adding or removing its internal members. Without the lock token, PUT and MKCOL could create new members, and DELETE, MOVE and COPY could remove, rename or add members of the locked collection. RFC 4918, section 7.5 states that a collection write lock, whether depth 0 or depth infinity, protects any request that would create a new resource in the collection, remove an internal member URL or change the segment name of an internal member. The lock of the direct parent collection is now checked for these requests whatever its depth.
| } else { | ||
| // parentPath == path is a check for the first loop | ||
| if (parentPath == path || parentLock.depth > 0) { | ||
| if (parentPath == path || parentLock.depth > 0 || directParent) { |
| if (lock != null) { | ||
| // The shared lock might not have the same depth | ||
| if (parentPath == path || lock.depth > 0) { | ||
| if (parentPath == path || lock.depth > 0 || directParent) { |
| if (slash < 0) { | ||
| break; | ||
| } | ||
| directParent = memberChange && parentPath == path; |
Member
Author
There was a problem hiding this comment.
Intentional: parentPath is the same instance as path only on the first iteration, same idiom as the existing checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A depth 0 write lock on a collection does not prevent other clients from adding or removing its internal members. Without the lock token, PUT and MKCOL create new members and DELETE, MOVE and COPY remove, rename or add members of the locked collection.
RFC 4918, section 7: "Clients MUST submit a lock-token they are authorized to use in any request that modifies a write-locked resource", and for collections this covers "any modification of an internal member URI". Section 7.5 states that a collection write lock, "whether created with a "Depth: 0" or "Depth: infinity" header", protects any request that would create a new resource in the collection, remove an internal member URL or change the segment name of an internal member.
isLocked()only considered ancestor locks with a depth greater than 0. The lock of the direct parent collection is now also checked, whatever its depth, for the requests that change its membership: PUT of a new resource, MKCOL, DELETE, the source of MOVE and the destination of COPY and MOVE.Tested on a local Tomcat with
LOCK /a/andDepth: 0, requests sent without the lock token:PUT /a/newMKCOL /a/sub/DELETE /a/mMOVE /a/mto/m2MOVE /a/mto/a/m3MOVE /outto/a/inCOPY /outto/a/cPUT /a/m(existing member)PUT /a/newwithIf: </a> (<token>)httpd mod_dav rejects the same requests. The new test in TestWebdavServlet fails without the change.