Gocryptfs: What happens if gocryptfs.diriv is deleted or corrupt?

Created on 20 Aug 2017  路  4Comments  路  Source: rfjakob/gocryptfs

Hello, I'm using gocryptfs to back up sensitive data in the cloud, but I had a question about the names of the files, about gocryptfs.diriv, if it is corrupted or altered I will lose all the contents inside the folder even with the masterkey, I did a test trying to mount without this file in the folders and I could not access, I would have to implement something that when he tried to mount msm without this file he would generate random names for the files, because even then the contents of the files would remain, thanks.

question

Most helpful comment

File names in the root directory are lost. File content in the root directory can be recovered. File content and file names in subdirectories are not affected.

All 4 comments

If gocryptfs.diriv is lost or corrupted, you lose the file names, but you can still recover the file contents by renaming the encrypted files:

$ gocryptfs -q cipherdir mountpoint
Password: 
$ mkdir mountpoint/dir1
$ echo xxxx > mountpoint/dir1/file1
$ ls -l cipherdir/
gocryptfs.conf          gocryptfs.diriv         vLQyBu4ODwkwHcgtStCdIg/
$ rm -f cipherdir/vLQyBu4ODwkwHcgtStCdIg/gocryptfs.diriv 
$ ls mountpoint/dir1
ls: cannot open directory 'mountpoint/dir1': No such file or directory
$ dd if=/dev/urandom bs=16 of=cipherdir/vLQyBu4ODwkwHcgtStCdIg/gocryptfs.diriv count=1
$ ls mountpoint/dir1
ls: cannot open directory 'mountpoint/dir1': Input/output error
$ ls -l cipherdir/vLQyBu4ODwkwHcgtStCdIg/
total 8
-rw-rw-r--. 1 jakob jakob 55 20. Aug 19:11 eFOixVOiMiZG6IdP20yPUg
-rw-rw-r--. 1 jakob jakob 16 20. Aug 19:13 gocryptfs.diriv
$ touch mountpoint/dir1/file2
$ ls -l cipherdir/vLQyBu4ODwkwHcgtStCdIg
total 8
-rw-rw-r--. 1 jakob jakob 55 20. Aug 19:11 eFOixVOiMiZG6IdP20yPUg
-rw-rw-r--. 1 jakob jakob 16 20. Aug 19:13 gocryptfs.diriv
-rw-rw-r--. 1 jakob jakob  0 20. Aug 19:13 sRp350EAU4MROozuoaI9Vg
$ mv cipherdir/vLQyBu4ODwkwHcgtStCdIg/eFOixVOiMiZG6IdP20yPUg cipherdir/vLQyBu4ODwkwHcgtStCdIg/sRp350EAU4MROozuoaI9Vg
$ ls mountpoint/dir1
file2
$ cat mountpoint/dir1/file2 
xxxx

I guess this is good to close?

Sorry to revive this but it seems appropriate to be here:

Any idea to recover the data if the gocryptfs.diriv in the _root_ of the mount directory is corrupted?

File names in the root directory are lost. File content in the root directory can be recovered. File content and file names in subdirectories are not affected.

Was this page helpful?
0 / 5 - 0 ratings