aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cryptfs/names_diriv.go2
-rw-r--r--pathfs_frontend/fs.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/cryptfs/names_diriv.go b/cryptfs/names_diriv.go
index 6346bc2..be7a2b1 100644
--- a/cryptfs/names_diriv.go
+++ b/cryptfs/names_diriv.go
@@ -10,6 +10,7 @@ import (
// readDirIV - read the "gocryptfs.diriv" file from "dir" (absolute path)
func (be *CryptFS) readDirIV(dir string) (iv []byte, err error) {
ivfile := filepath.Join(dir, DIRIV_FILENAME)
+ Debug.Printf("readDirIV: reading %s\n", ivfile)
iv, err = ioutil.ReadFile(ivfile)
if err != nil {
Warn.Printf("readDirIV: %v\n", err)
@@ -63,6 +64,7 @@ func (be *CryptFS) DecryptPathDirIV(encryptedPath string, rootDir string) (strin
var wd = rootDir
var plainNames []string
encryptedNames := strings.Split(encryptedPath, "/")
+ Debug.Printf("DecryptPathDirIV: decrypting %v\n", encryptedNames)
for _, encryptedName := range encryptedNames {
iv, err := be.readDirIV(wd)
if err != nil {
diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go
index c2b80a3..d999632 100644
--- a/pathfs_frontend/fs.go
+++ b/pathfs_frontend/fs.go
@@ -89,7 +89,15 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
// silently ignore "gocryptfs.diriv" everywhere if dirIV is enabled
continue
}
- name, err := fs.decryptPath(cName)
+ var name string
+ if !fs.dirIV {
+ name, err = fs.decryptPath(cName)
+ } else {
+ // When dirIV is enabled we need the full path to be able to decrypt it
+ cPath := filepath.Join(cDirName, cName)
+ name, err = fs.decryptPath(cPath)
+ name = filepath.Base(name)
+ }
if err != nil {
cryptfs.Warn.Printf("Invalid name \"%s\" in dir \"%s\": %s\n", cName, dirName, err)
continue