-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
extend fix-key-location to handle cases from broken cross-storage moves #36068
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
5ed04ea
to
0e6110e
Compare
$systemKeyPath = $this->getSystemKeyPath($node); | ||
|
||
if ($this->rootView->file_exists($systemKeyPath)) { | ||
// already has a key, reject new key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively we could check if the mtime of the new key is higher than the existing one and then overwrite.
and don't overwrite is mtime is lower
a higher mtime would mean that the file has been overwritten by another user despite being not decryptable (not sure if possible though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As is, this code path shouldn't be reached if a system key already exists, the check is mostly there as an extra safety rail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one 👍
would this also work with primary object store, seeing that there's code that states that keys might not be in filecache, but filecache is needed for primary object store ?
$this->rootView->copy($key, $systemKeyPath); | ||
|
||
try { | ||
if (!$storage->instanceOfStorage(Encryption::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it mean this command works even with encryption app disabled ? maybe add a comment here to answer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command itself is part of the encryption app, so no
might be useful to add more debug logging / verbose output for each step in this complex algorithm, to be able to trace back repair problems and/or cases we haven't found yet then we can ask people to run with -vvvv also wondering if we should add a ctrl+c trap that only allow shutdown between two files, to avoid having a mess if an admin abort while we test keys combinations (where we put it in a place then delete again if it doesn't work). |
0e6110e
to
bb3262c
Compare
bb3262c
to
db06b6c
Compare
db06b6c
to
e890d1d
Compare
e890d1d
to
fc6df38
Compare
Signed-off-by: Robin Appelman <[email protected]>
fc6df38
to
e4f8522
Compare
Signed-off-by: Robin Appelman <[email protected]>
Fixes files not being decrypted when moved cross-storage due to (#35894) (ab)using the fact that the encrypted flag wasn't cleared for them (#35961) to find these cases.
If a working key can be found for the files they are decrypted in place, leaving the encrypted file as a backup to reduce chances of errors leading to further data loss.
This currently only works if the file hasn't been renamed after being moved because the file name is being used to try and find possible encryption keys. A possible further step would be to add an option to check every available key, covering more cases at the cost of performance.
A special case was also added for when encryption is enabled for the storage after encrypted files have been moved. In those cases the found key is copied to the correct location.
The "fix-key-location" name of the command isn't fully applicable anymore so it might make sense to give it a new name.
To test:
occ encryption:fix-key-location <user>
Alternatively add step 3.5
occ config:app:set groupfolders enable_encryption --value true
to enable groupfolder encryptionBackport note: this currently reuses the normal encryption logic to determine which mountpoints are "system" mountpoints, previous nc versions didn't handle groupfolders for that properly. So some extra logic for that will probsbly need to be added for backports.