summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go12
-rw-r--r--pathfs_frontend/fs.go21
2 files changed, 22 insertions, 11 deletions
diff --git a/main.go b/main.go
index 06864d5..1fdd242 100644
--- a/main.go
+++ b/main.go
@@ -61,11 +61,13 @@ func initDir(args *argContainer) {
os.Exit(ERREXIT_INIT)
}
- // Create gocryptfs.diriv in the root dir
- err = cryptfs.WriteDirIV(args.cipherdir)
- if err != nil {
- fmt.Println(err)
- os.Exit(ERREXIT_INIT)
+ if args.diriv && !args.plaintextnames {
+ // Create gocryptfs.diriv in the root dir
+ err = cryptfs.WriteDirIV(args.cipherdir)
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(ERREXIT_INIT)
+ }
}
cryptfs.Info.Printf("The filesystem is now ready for mounting.\n")
diff --git a/pathfs_frontend/fs.go b/pathfs_frontend/fs.go
index 0f462b0..8d05c02 100644
--- a/pathfs_frontend/fs.go
+++ b/pathfs_frontend/fs.go
@@ -90,7 +90,7 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
return nil, fuse.ToStatus(err)
}
}
- // Decrypt filenames
+ // Filter and decrypt filenames
var plain []fuse.DirEntry
for i := range cipherEntries {
cName := cipherEntries[i].Name
@@ -102,11 +102,13 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
// silently ignore "gocryptfs.diriv" everywhere if dirIV is enabled
continue
}
- var name string
- name, err = fs.CryptFS.DecryptName(cName, cachedIV, fs.args.EMENames)
- if err != nil {
- cryptfs.Warn.Printf("Invalid name \"%s\" in dir \"%s\": %s\n", cName, dirName, err)
- continue
+ var name string = cName
+ if !fs.args.PlaintextNames {
+ name, err = fs.CryptFS.DecryptName(cName, cachedIV, fs.args.EMENames)
+ if err != nil {
+ cryptfs.Warn.Printf("Invalid name \"%s\" in dir \"%s\": %s\n", cName, dirName, err)
+ continue
+ }
}
cipherEntries[i].Name = name
plain = append(plain, cipherEntries[i])
@@ -251,6 +253,10 @@ func (fs *FS) Mkdir(relPath string, mode uint32, context *fuse.Context) (code fu
if err != nil {
return fuse.ToStatus(err)
}
+ if !fs.args.DirIV {
+ return fuse.ToStatus(os.Mkdir(encPath, os.FileMode(mode)))
+ }
+
// The new directory may take the place of an older one that is still in the cache
fs.CryptFS.DirIVCacheEnc.Clear()
// Create directory
@@ -290,6 +296,9 @@ func (fs *FS) Rmdir(name string, context *fuse.Context) (code fuse.Status) {
if err != nil {
return fuse.ToStatus(err)
}
+ if !fs.args.DirIV {
+ return fuse.ToStatus(syscall.Rmdir(encPath))
+ }
// If the directory is not empty besides gocryptfs.diriv, do not even
// attempt the dance around gocryptfs.diriv.