From d1762c5b95c3279b0a2dfa3df5c99fe59922b666 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 20 Sep 2016 20:59:02 +0200 Subject: [PATCH] reverse: fix GetAttr for gocryptfs.conf And also don't return the encrypted version of .gocryptfs.reverse.conf in readdir. --- internal/fusefrontend_reverse/rfs.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go index 98f6279..e20c851 100644 --- a/internal/fusefrontend_reverse/rfs.go +++ b/internal/fusefrontend_reverse/rfs.go @@ -101,6 +101,9 @@ func isDirIV(relPath string) bool { // GetAttr - FUSE call func (rfs *reverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status) { + if relPath == configfile.ConfDefaultName { + return rfs.loopbackfs.GetAttr(configfile.ConfReverseName, context) + } if isDirIV(relPath) { return rfs.dirIVAttr(relPath, context) } @@ -174,18 +177,15 @@ func (rfs *reverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse. // Encrypt names dirIV := deriveDirIV(cipherPath) for i := range entries { - entries[i].Name = rfs.nameTransform.EncryptName(entries[i].Name, dirIV) + // ".gocryptfs.reverse.conf" in the root directory is mapped to "gocryptfs.conf" + if cipherPath == "" && entries[i].Name == configfile.ConfReverseName { + entries[i].Name = configfile.ConfDefaultName + } else { + entries[i].Name = rfs.nameTransform.EncryptName(entries[i].Name, dirIV) + } } // Add virtual gocryptfs.diriv entries = append(entries, fuse.DirEntry{syscall.S_IFREG | 0400, nametransform.DirIVFilename}) - // Add gocryptfs.conf in the root directory, - // maps to .gocryptfs.reverse.conf in the plaintext directory. - if cipherPath == "" { - _, err = os.Stat(filepath.Join(rfs.args.Cipherdir, configfile.ConfReverseName)) - if err == nil { - entries = append(entries, fuse.DirEntry{syscall.S_IFREG | 0400, configfile.ConfDefaultName}) - } - } return entries, fuse.OK }