Repository navigation
Fix share key pattern matching - #11137
Conversation
|
looks good. And great to have a test! 👍 |
|
@LukasReschke @schiesbn The remaining problem is the pattern like: The keys become: If you move file "test.txt" it will also match the key from "test.txt.backup". File 1: "test.txt.firstname.lastname.shareKey" Still looking for a quick solution that doesn't require changing the key name format... |
|
CC @ser72 see previous comment for problem I talk with you about |
Don't we know the user name at this point? |
|
We need the share keys of all users who have access, not only the current one. Resolving the user names (checking for matches) can be slow (LDAP...). Alternative: Getting the list of users who have access to the file is possible but complex due to reshares. The algo exists somewhere and might be reusable. Another quick fix idea: if a matched key might match another file name, exclude it. There's one other scenario with a user "user1" and "user1.test" with the files "file.user1" and "file.user1.test" where it could still mess up... Hopefully much rare. Ultimate solution would be to put all share keys of a file inside a sub folder with the file name. Migration is a concern... |
|
Part of this problem also exists on OC 6.0.5 where |
|
I just checked the trash bin, the trash bin still uses glob() to get all share keys. I think it would make sense to change the trash bin to use the same methods as files_encryption to collect the share keys. |
|
Then also the question how to fix stable6 which only uses glob... should we use preg_match there as well then ? (separate PR) |
Trashbin glob will be fixed separately... |
|
|
That approach worked. |
Please review @schiesbn @LukasReschke @icewind1991 @th3fallen |
|
Doing some local testing as well. Already found an issue with the sync client 😦 |
|
Bad news, it seems that this fix is still not enough. |
|
The problem happens when the owner changes:
Will compare with master and try and find a solution. |
|
I raised #11162 for the warnings I saw in the log, but when using only one file that file is not broken after move. I'll continue to debug. |
|
Please carry on testing/reviewing, that issue is completely different and unrelated to file name patterns. See #11162 for details. |
|
Test plan:
Testing deletionWith trashbin enabled
With trashbin disabled
Other
Testing move / copy
|
|
|
Ok... I'll retest these bugs and see whether they happen on master and raise tickets if needed. |
|
I have raised three tickets for the issues that exist on stable7. |
|
|
I give up on trying to write unit tests for that. Too many static classes, not enough dependency injection. It's simply not possible in a short time frame. So I tested the system mount point case manually: moving a file from "/mount" to "/mount/file2" when the mount point is accessible to multiple users. This correctly moves the share keys to the new folder. |
|
Seems it all works now. Please help review and testing. @schiesbn |
|
🚀 Test Passed. 🚀 |
There was a problem hiding this comment.
Doesn't we have the same problem again, that we could match the wrong share keys with preg_match() ?
There was a problem hiding this comment.
Think about two users, "name2" and "name1.name2". You want to delete all shares keys for "name2". With the preg_match statement above you would also delete the share key for user "name1.name2", right?
There was a problem hiding this comment.
Hmm right, the wildcard (.*) that is before might match too much, including the left part of the wrong user name.
There was a problem hiding this comment.
Wrote a unit test, indeed it can happen... will see whether I can just reuse the $realFile somehow.
|
@schiesbn I fixed the part and added further unit tests. |
|
@schiesbn see a8b55b4 where I have also fixed the trashbin share key matching using the helper, as you advised. |
|
🚀 Test PASSed. 🚀 |
|
🚀 Test PASSed. 🚀 |
|
looks good 👍 |
|
Thanks. Needs another reviewer please @LukasReschke @icewind1991 To test the trashbin part you need to create two files "test.txt" and "text.txt.backup". Before the fix, deleting "test.txt" would kill both file's share keys. After the fix the correct key is removed. For the former part please have a look at the original ticket, the pattern is "test.txt" and "test_review.txt" and involves a WebDAV MOVE into a subdir within a shared folder. |
|
Code looks good 👍 |
|
Thanks guys. Going to squash this first. |
Instead of inaccurate pattern matching, use the list of users who we know have access to the file to build the list of share keys. This covers the following cases: - Move/copy files into a subfolder within a share - Unsharing from a user - Deleting files directlry / moving share keys to trashbin
a8b55b4 to
1e63175
Compare
|
I just squashed them all into one commit. |
Fix share key pattern matching
|
A new inspection was created. |
|
@karlitschek please confirm backport for stable7 and stable6 (stable6 will be done later as it might need a different approach) |
|
backporting confirmed |
|
Raised #11297 for the last issue related to having user names in file names. |
Fixes #11127
But there's another failing pattern, unit test will fail.
Still looking for a solution...