server icon indicating copy to clipboard operation
server copied to clipboard

Add an occ command to scan files for legacy file key in use and get rid of those

Open come-nc opened this issue 2 years ago • 1 comments

  • Resolves: #37918

Summary

Add an occ command to scan files for legacy key format, and migrate those to the new format. Only works if master key is enabled.

Checklist

come-nc avatar May 04 '23 14:05 come-nc

@icewind1991 So, this is currently broken, because opening with mode r+ does not touch the header. See https://github.com/nextcloud/server/blob/master/lib/private/Files/Stream/Encryption.php#L287-L292 Same problem in https://github.com/nextcloud/server/blob/master/apps/encryption/lib/Crypto/Encryption.php#L221-L225 Is r+ mode supported at all by server side encryption?

come-nc avatar May 04 '23 16:05 come-nc

So, I was not able to do this in a smart way, in the end the whole file has to be written again anyway since the header at the beginning needs to change. So I went for the same implementation as the DecryptAll class, I copy to a temporary name and move over the existing file. But it works, after running the fileKeys are gone and the encrypted files can still be opened.

Ready for review.

come-nc avatar May 09 '23 10:05 come-nc

Ok this is now working and not losing fileid anymore. It will be slow sadly but I do not see how to avoid that.

Ready for review.

come-nc avatar May 11 '23 09:05 come-nc

CI failures not related

come-nc avatar May 11 '23 15:05 come-nc

Is there any plans to update the documentation on server side encryption or write some documentation on the migration process using this new occ command ?

If a follow up PR on the documentation of the migration process exists, could it be please linked here ? I could also open such a PR but I'm afraid I'm not enough knowledgeable in Nextcloud and don't have at the moment a dev environment to test NC27 Beta 2.

AkechiShiro avatar May 15 '23 12:05 AkechiShiro

@AkechiShiro Still needs someone to pick it up, but tracking doc addition in nextcloud/documentation#11539. Thanks for the reminder!

joshtrichards avatar Feb 13 '24 15:02 joshtrichards