diff options
author | Jakob Unterwurzacher | 2016-10-08 21:14:16 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-10-08 21:14:16 +0200 |
commit | e47577834bcb7bde3d06923f0feffc5ac5ca84dd (patch) | |
tree | af336040f553c2692e03f799f91d47ee54a09bac | |
parent | f054353bd3b05ab0d3d024ec8fa809bc5fed1d08 (diff) |
reverse: merge config translation check into isTranslatedConfig
Also get rid of useless isFiltered function.
-rw-r--r-- | internal/fusefrontend_reverse/rfs.go | 30 | ||||
-rw-r--r-- | internal/fusefrontend_reverse/rpath.go | 4 |
2 files changed, 20 insertions, 14 deletions
diff --git a/internal/fusefrontend_reverse/rfs.go b/internal/fusefrontend_reverse/rfs.go index 36f49be..91ec543 100644 --- a/internal/fusefrontend_reverse/rfs.go +++ b/internal/fusefrontend_reverse/rfs.go @@ -128,6 +128,20 @@ func (rfs *reverseFS) isNameFile(relPath string) bool { return fileType == nametransform.LongNameFilename } +// isTranslatedConfig returns true if the default config file name is in +// and the ciphertext path is "gocryptfs.conf". +// "gocryptfs.conf" then maps to ".gocryptfs.reverse.conf" in the plaintext +// directory. +func (rfs *reverseFS) isTranslatedConfig(relPath string) bool { + if rfs.args.ConfigCustom { + return false + } + if relPath == configfile.ConfDefaultName { + return true + } + return false +} + func (rfs *reverseFS) inoAwareStat(relPlainPath string) (*fuse.Attr, fuse.Status) { absPath, err := rfs.abs(relPlainPath, nil) if err != nil { @@ -165,7 +179,7 @@ func (rfs *reverseFS) inoAwareStat(relPlainPath string) (*fuse.Attr, fuse.Status // GetAttr - FUSE call func (rfs *reverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status) { - if relPath == configfile.ConfDefaultName { + if rfs.isTranslatedConfig(relPath) { return rfs.inoAwareStat(configfile.ConfReverseName) } // Handle virtual files @@ -207,11 +221,11 @@ func (rfs *reverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr // Access - FUSE call func (rfs *reverseFS) Access(relPath string, mode uint32, context *fuse.Context) fuse.Status { - if rfs.isDirIV(relPath) { + if rfs.isTranslatedConfig(relPath) { return fuse.OK } - if rfs.isFiltered(relPath) { - return fuse.EPERM + if rfs.isDirIV(relPath) { + return fuse.OK } absPath, err := rfs.abs(rfs.decryptPath(relPath)) if err != nil { @@ -222,8 +236,7 @@ func (rfs *reverseFS) Access(relPath string, mode uint32, context *fuse.Context) // Open - FUSE call func (rfs *reverseFS) Open(relPath string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) { - if relPath == configfile.ConfDefaultName { - // gocryptfs.conf maps to .gocryptfs.reverse.conf in the plaintext directory + if rfs.isTranslatedConfig(relPath) { return rfs.loopbackfs.Open(configfile.ConfReverseName, flags, context) } if rfs.isDirIV(relPath) { @@ -232,9 +245,6 @@ func (rfs *reverseFS) Open(relPath string, flags uint32, context *fuse.Context) if rfs.isNameFile(relPath) { return rfs.newNameFile(relPath) } - if rfs.isFiltered(relPath) { - return nil, fuse.EPERM - } return rfs.NewFile(relPath, flags) } @@ -294,7 +304,7 @@ func (rfs *reverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse. for i := range entries { var cName string // ".gocryptfs.reverse.conf" in the root directory is mapped to "gocryptfs.conf" - if cipherPath == "" && entries[i].Name == configfile.ConfReverseName { + if cipherPath == "" && rfs.isTranslatedConfig(entries[i].Name) { cName = configfile.ConfDefaultName } else { cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV) diff --git a/internal/fusefrontend_reverse/rpath.go b/internal/fusefrontend_reverse/rpath.go index ca8c442..5288dcd 100644 --- a/internal/fusefrontend_reverse/rpath.go +++ b/internal/fusefrontend_reverse/rpath.go @@ -85,7 +85,3 @@ func (rfs *reverseFS) decryptPath(relPath string) (string, error) { } return filepath.Join(transformedParts...), nil } - -func (rfs *reverseFS) isFiltered(relPath string) bool { - return false -} |