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

[stable30] Fix renaming a received share by a user with stale shares #50228

Open
wants to merge 2 commits into
base: stable30
Choose a base branch
from

Conversation

danxuliu
Copy link
Member

If a user tries to rename a received share and that user has stale shares (shares where the source file was deleted) an internal server error is triggered.

The problem comes from checking the existing shares to ensure that the share is not moved inside one of them. If the source file of a share made by the user was deleted when the node is tried to be got a OCP\Files\NotFoundException is thrown; this is not caught anywhere and causes an internal server error.

In master the problem was fixed by c2ca99e. After that change getSharesBy filters out shares with a no longer accessible node, so targetIsNotShared no longer throws an exception. However, the pull request that the commit belongs to has not been backported to the stable branches (and I assume that it will not be, as it is a new feature), so the issue is still present in the stable versions of Nextcloud.

c2ca99e looks like a sane check independently of the rest of #49073, so I have cherry-picked just that commit (and added integration tests for the issue). But I do not really know if that could have any problematic side effect 🤷 so a careful review is encouraged :-)

How to test

  • Setup Nextcloud
  • Add users admin and user0
  • As admin, create a folder (curl --user admin:admin --request MKCOL --header "OCS-APIRequest: true" "http://127.0.0.1:8000/remote.php/dav/files/admin/folder-to-be-deleted")
  • Share the folder with user0 (curl --user admin:admin --request POST --header "OCS-APIRequest: true" "http://127.0.0.1:8000/ocs/v1.php/apps/files_sharing/api/v1/shares?path=folder-to-be-deleted&shareType=0&shareWith=user0")
  • Delete the folder (curl --user admin:admin --request DELETE --header "OCS-APIRequest: true" "http://127.0.0.1:8000/remote.php/dav/files/admin/folder-to-be-deleted")
  • As user0, create a folder (curl --user user0:123456 --request MKCOL --header "OCS-APIRequest: true" "http://127.0.0.1:8000/remote.php/dav/files/user0/folder-to-be-renamed")
  • Share the folder with admin (curl --user user0:123456 --request POST --header "OCS-APIRequest: true" "http://127.0.0.1:8000/ocs/v1.php/apps/files_sharing/api/v1/shares?path=folder-to-be-renamed&shareType=0&shareWith=admin")
  • As admin, try to rename the received share (curl --user admin:admin --request MOVE --header "OCS-APIRequest: true" --header "Destination: http://127.0.0.1:8000/remote.php/dav/files/admin/new-folder-name" "http://127.0.0.1:8000/remote.php/dav/files/admin/folder-to-be-renamed")

Result with this pull request

The received share is renamed

Result without this pull request

Internal server error

@danxuliu
Copy link
Member Author

/backport to stable29

@danxuliu
Copy link
Member Author

Mmmm, it seems that it would be necessary to also backport 715e714, so this is starting to feel riskier than expected. And it also changes the signature of IManager, so I guess that a different approach would be needed anyway for stable branches 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants