diff options
author | Jakob Unterwurzacher | 2016-02-06 19:27:59 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-02-06 19:27:59 +0100 |
commit | 9078a77850dd680bfa938d9ed7c83600a60c0e7b (patch) | |
tree | 03ee83879c398307d450002e1f07e928cb743672 /internal/fusefrontend/names.go | |
parent | 2b8cbd944149afe51fadddbd67ee4499d1d86250 (diff) |
Move pathfs_frontend to internal/fusefrontend
"git status" for reference:
renamed: pathfs_frontend/args.go -> internal/fusefrontend/args.go
renamed: pathfs_frontend/compat_darwin.go -> internal/fusefrontend/compat_darwin.go
renamed: pathfs_frontend/compat_linux.go -> internal/fusefrontend/compat_linux.go
renamed: pathfs_frontend/file.go -> internal/fusefrontend/file.go
renamed: pathfs_frontend/file_holes.go -> internal/fusefrontend/file_holes.go
renamed: pathfs_frontend/fs.go -> internal/fusefrontend/fs.go
renamed: pathfs_frontend/fs_dir.go -> internal/fusefrontend/fs_dir.go
renamed: pathfs_frontend/names.go -> internal/fusefrontend/names.go
renamed: pathfs_frontend/write_lock.go -> internal/fusefrontend/write_lock.go
modified: main.go
Diffstat (limited to 'internal/fusefrontend/names.go')
-rw-r--r-- | internal/fusefrontend/names.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/names.go new file mode 100644 index 0000000..5760c87 --- /dev/null +++ b/internal/fusefrontend/names.go @@ -0,0 +1,52 @@ +package fusefrontend + +// This file forwards file encryption operations to cryptfs + +import ( + "github.com/rfjakob/gocryptfs/internal/configfile" + mylog "github.com/rfjakob/gocryptfs/internal/toggledlog" +) + +// isFiltered - check if plaintext "path" should be forbidden +// +// Prevents name clashes with internal files when file names are not encrypted +func (fs *FS) isFiltered(path string) bool { + if !fs.args.PlaintextNames { + return false + } + // gocryptfs.conf in the root directory is forbidden + if path == configfile.ConfDefaultName { + mylog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n", + configfile.ConfDefaultName) + return true + } + // Note: gocryptfs.diriv is NOT forbidden because diriv and plaintextnames + // are exclusive + return false +} + +// encryptPath - encrypt relative plaintext path +func (fs *FS) encryptPath(plainPath string) (string, error) { + if fs.args.PlaintextNames { + return plainPath, nil + } + if !fs.args.DirIV { + return fs.nameTransform.EncryptPathNoIV(plainPath), nil + } + fs.dirIVLock.RLock() + defer fs.dirIVLock.RUnlock() + return fs.nameTransform.EncryptPathDirIV(plainPath, fs.args.Cipherdir) +} + +// decryptPath - decrypt relative ciphertext path +func (fs *FS) decryptPath(cipherPath string) (string, error) { + if fs.args.PlaintextNames { + return cipherPath, nil + } + if !fs.args.DirIV { + return fs.nameTransform.DecryptPathNoIV(cipherPath) + } + fs.dirIVLock.RLock() + defer fs.dirIVLock.RUnlock() + return fs.nameTransform.DecryptPathDirIV(cipherPath, fs.args.Cipherdir, fs.args.EMENames) +} |