Fix exception on external storages public links when encryption enabled
Description
Having masterkey encryption enabled, when trying to upload into a public link created on an external storage (i.e. of type "Local" or "WND") being assigned to at least one user/group, an exception Attempted to initialize mount points for null user and no user in session is being thrown and no upload is possible.
Related Issue
- Fixes https://github.com/owncloud/enterprise/issues/6626
Motivation and Context
There was a problem around https://github.com/owncloud/core/blob/master/lib/private/Encryption/Util.php#L303 as the uid provided to the method is false in this case. This happens because the external storage doesn't really have an owner and there is no user in the session. Therefore, when checking for isMountPointApplicableToUser, the provided user is false which will never find a match, so the mount point isn't considered system wide.
How Has This Been Tested?
- enable masterkey encryption
- create an external storage through the "local" option (also reproducible with WND) and mount it for user
admin - as user
admincreates a public link on the external storage root - try to upload into the created public link: an exception
Attempted to initialize mount points for null user and no user in sessionis shown and file cannot be uploaded - try to download an existing file works. Try to download any other file added by user
adminafter the storage has been mounted into oC fails withFile cannot be downloadedand same exception in logs - With this change in place both exceptions at 4. and 5. are solved.
Types of changes
- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Database schema changes (next release will require increase of minor version instead of patch)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Technical debt
- [ ] Tests only (no source changes)
Checklist:
- [X] Code changes
- [ ] Unit tests added
- [ ] Acceptance tests added
- [ ] Documentation ticket raised
- [x] Changelog item
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
There was an additional problem according to https://github.com/owncloud/enterprise/issues/6626#issuecomment-2084853496 , is it solved? or will it be fixed later?
There was an additional problem according to https://github.com/owncloud/enterprise/issues/6626#issuecomment-2084853496 , is it solved? or will it be fixed later?
I guess we can try to fix it here. But I don't quite get why we are not getting into https://github.com/owncloud/core/blob/master/lib/private/Preview.php#L1229-L1231 as $user should be empty at that point.
https://github.com/owncloud/core/blob/master/lib/private/Files/View.php#L1475
The user isn't empty. It's likely a RemoteUser.
The case where the user is false isn't being handled properly. Even if the storage returns a null or false owner, the view will consider it as a remote user. I guess that's what the Filesystem::getOwner is returning.
I guess that's what the Filesystem::getOwner is returning.
AFAICT from https://github.com/owncloud/core/blob/master/lib/private/Preview.php#L1228 we get false back.
Note: a changelog was added by #41247 but was named https://github.com/owncloud/core/blob/master/changelog/unreleased/41246
So that is why there is a conflict here!
I made #41248 to fix that.
@pako81 is this ready to go into 10.15.0?
After 10.15.0 - converting to draft for now.
cleaning up - I think this is no longer of anybody's interest