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

cannot PROPFIND a received share with name when it was created, shared, deleted, recreated, reshared #7895

Closed
individual-it opened this issue Dec 6, 2023 · 4 comments
Assignees
Labels

Comments

@individual-it
Copy link
Member

Describe the bug

In the case when a user creates a folder, shares it, then deletes it, recreates and reshares it - the receiver cannot use PROPFIND with the resource name anymore

Steps to reproduce

# 1. the folder to create
foldername='subfolder'

# 2. set the token for the sharer
admintoken=''

# 3. get the id of the personal drive for the sharer
driveid=`curl -H"Authorization: Bearer $admintoken" "https://ocis.owncloud.test/graph/v1.0/me/drive" -k | jq .id -r`

# 4. as sharer create a folder
curl -XMKCOL -k -H"Authorization: Bearer $admintoken"  'https://ocis.owncloud.test/dav/spaces/'$driveid'/'$foldername

# 5. find the fileid of the created folder
fileid=`curl -XPROPFIND -k -H"Authorization: Bearer $admintoken"  'https://ocis.owncloud.test/dav/spaces/'$driveid'/'$foldername| xmllint --xpath '//*[local-name()="id"]/text()' -`

# 6. define the permission to share (the ids are hard-codded in ocis) 
viewer='b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5'

# 7. list the users
curl -k -H"Authorization: Bearer $admintoken" "https://ocis.owncloud.test/graph/v1.0/users" | jq

# 8. set the id of the receiver
einstein=''

# 9. share the folder
curl -k -H"Authorization: Bearer $admintoken" "https://ocis.owncloud.test/graph/v1beta1/drives/$driveid/items/$fileid/invite" -d '{"recipients":[{"objectId":"'$einstein'"}],"roles":["'$viewer'"]}'

# 10. get a token for the receiver
einsteintoken=""

# 11. find the drive id of the receivers share-space
einsteinsharesid=`curl -H"Authorization: Bearer $einsteintoken" "https://ocis.owncloud.test/graph/v1.0/me/drives" -k | jq -c '.[] | .[] | select(.driveAlias | contains("virtual/shares")) | .id' -r`

# 12. propfind the complete share space of the receiver, the created folder should be visible
curl -XPROPFIND -k -H"Authorization: Bearer $einsteintoken" 'https://ocis.owncloud.test/dav/spaces/'$einsteinsharesid'/' | xmllint --format -

# 13. propfind only the folder, that should work now
curl -XPROPFIND -k -H"Authorization: Bearer $einsteintoken" 'https://ocis.owncloud.test/dav/spaces/'$einsteinsharesid'/'$foldername | xmllint --format -

# 14. as sharer delete the folder
curl -XDELETE -k -H"Authorization: Bearer $admintoken"  'https://ocis.owncloud.test/dav/spaces/'$driveid'/'$foldername

# 15. as sharer create the same folder again
curl -XMKCOL -k -H"Authorization: Bearer $admintoken"  'https://ocis.owncloud.test/dav/spaces/'$driveid'/'$foldername

# 16. find the fileid of the created folder
fileid=`curl -XPROPFIND -k -H"Authorization: Bearer $admintoken"  'https://ocis.owncloud.test/dav/spaces/'$driveid'/'$foldername| xmllint --xpath '//*[local-name()="id"]/text()' -`

# 17. share the folder
curl -k -H"Authorization: Bearer $admintoken" "https://ocis.owncloud.test/graph/v1beta1/drives/$driveid/items/$fileid/invite" -d '{"recipients":[{"objectId":"'$einstein'"}],"roles":["'$viewer'"]}'

# 18. propfind the complete share space of the receiver, the created folder should be visible
curl -XPROPFIND -k -H"Authorization: Bearer $einsteintoken" 'https://ocis.owncloud.test/dav/spaces/'$einsteinsharesid'/' | xmllint --format -

# 19. propfind only the folder, THIS WILL BREAK, and if it does not, try again stating with point 14
curl -XPROPFIND -k -H"Authorization: Bearer $einsteintoken" 'https://ocis.owncloud.test/dav/spaces/'$einsteinsharesid'/'$foldername | xmllint --format -

Expected behavior

PROPFIND should work, not depending if the folder is recreated or not

Actual behavior

PROPFIND returns NotFound or even internal Error
The PROPFIND can still be done using the fileid of the created folder, that is how web does it

Setup

Please describe how you started the server and provide a list of relevant environment variables or configuration files.

docker compose file from: https://github.com/owncloud/ocis-php-sdk/blob/main/tests/integration/compose.yaml

Additional context

I've encountered the problem when writing tests for https://github.com/owncloud/ocis-php-sdk/ the test would work one time, but break the next time

@rhafer rhafer self-assigned this Feb 26, 2024
@rhafer
Copy link
Contributor

rhafer commented Feb 26, 2024

Just for completeness: This is not specific to sharing-ng happens also when creating the shares via ocs. (So I guess it's a bug in the sharestorageprovider)

@rhafer rhafer moved this from Qualification to In progress in Infinite Scale Team Board Feb 26, 2024
@rhafer
Copy link
Contributor

rhafer commented Mar 5, 2024

So basically the problem is, that we don't cleanup shares for a resource when the resource is being deleted. So when recreating (and sharing) a resource with the same name the shareprovider will return two shares when listing share by Mountpoint (which is what the sharestorageprovider needs to do for the PROPFIND). It will then just return the first share matching the mountpoint without actually checking if resource that the shared is pointing to still exist.

@rhafer rhafer changed the title [sharing-ng] cannot PROPFIND a received share with name when it was created, shared, deleted, recreated, reshared cannot PROPFIND a received share with name when it was created, shared, deleted, recreated, reshared Mar 5, 2024
@rhafer
Copy link
Contributor

rhafer commented Mar 5, 2024

This is a basically a duplicate of: #1787 🙈

rhafer added a commit to rhafer/reva that referenced this issue Mar 6, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
rhafer added a commit to rhafer/reva that referenced this issue Mar 6, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
rhafer added a commit to rhafer/reva that referenced this issue Mar 6, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
rhafer added a commit to rhafer/ocis that referenced this issue Mar 6, 2024
rhafer added a commit to cs3org/reva that referenced this issue Mar 7, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
rhafer added a commit to rhafer/ocis that referenced this issue Mar 7, 2024
rhafer added a commit to rhafer/ocis that referenced this issue Mar 7, 2024
@rhafer
Copy link
Contributor

rhafer commented Mar 7, 2024

Fix was merged as part of #8472

rhafer added a commit to rhafer/reva that referenced this issue Mar 12, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
(cherry picked from commit fa2caba)
rhafer added a commit to cs3org/reva that referenced this issue Mar 12, 2024
When resolving a received shared by mountpath, make sure that the
shared resource actually exists. This avoids issues with dangling shares
for already delete resources using the same mountpoint.

Fixes: owncloud/ocis#7895
(cherry picked from commit fa2caba)
@rhafer rhafer closed this as completed Apr 4, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Infinite Scale Team Board Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants