fix: Prefer mount owner over current user as owner of the storage #3538
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.
Fixes nextcloud/server#40090 (comment)
This pull request fixes an issue where the current user is wrongly assumed as the storage owner. This then may lead to the files_versions app not being able to store a version properly, ending up with a file that cannot be saved in a rather specific scenario:
Steps to reproduce:
I'm not sure if there is a case where this could also be triggered without collabora.
We set userB in richdocuments as the active user
https://github.com/nextcloud/richdocuments/blob/b4b76b4b326005eb469b13643bfe7e2d9fdcb580/lib/Controller/WopiController.php#L436
This then later on fails when files_versions tries to get path for the node:
https://github.com/nextcloud/server/blob/369274c9ee82eed6010a1a3b9cc5bac1a9926e2c/apps/files_versions/lib/Listener/FileEventsListener.php#L374-L383
For the mountpoint of a share we should still assume the mount owner as the storage owner instead of always taking the current user. Using the user from the session used to be the fallback for any storage that does have shared ownership, but we can be more specific here with the mount owner.