reverse: merge config translation check into isTranslatedConfig
Also get rid of useless isFiltered function.
This commit is contained in:
parent
f054353bd3
commit
e47577834b
@ -128,6 +128,20 @@ func (rfs *reverseFS) isNameFile(relPath string) bool {
|
|||||||
return fileType == nametransform.LongNameFilename
|
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) {
|
func (rfs *reverseFS) inoAwareStat(relPlainPath string) (*fuse.Attr, fuse.Status) {
|
||||||
absPath, err := rfs.abs(relPlainPath, nil)
|
absPath, err := rfs.abs(relPlainPath, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -165,7 +179,7 @@ func (rfs *reverseFS) inoAwareStat(relPlainPath string) (*fuse.Attr, fuse.Status
|
|||||||
|
|
||||||
// GetAttr - FUSE call
|
// GetAttr - FUSE call
|
||||||
func (rfs *reverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
|
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)
|
return rfs.inoAwareStat(configfile.ConfReverseName)
|
||||||
}
|
}
|
||||||
// Handle virtual files
|
// Handle virtual files
|
||||||
@ -207,11 +221,11 @@ func (rfs *reverseFS) GetAttr(relPath string, context *fuse.Context) (*fuse.Attr
|
|||||||
|
|
||||||
// Access - FUSE call
|
// Access - FUSE call
|
||||||
func (rfs *reverseFS) Access(relPath string, mode uint32, context *fuse.Context) fuse.Status {
|
func (rfs *reverseFS) Access(relPath string, mode uint32, context *fuse.Context) fuse.Status {
|
||||||
if rfs.isDirIV(relPath) {
|
if rfs.isTranslatedConfig(relPath) {
|
||||||
return fuse.OK
|
return fuse.OK
|
||||||
}
|
}
|
||||||
if rfs.isFiltered(relPath) {
|
if rfs.isDirIV(relPath) {
|
||||||
return fuse.EPERM
|
return fuse.OK
|
||||||
}
|
}
|
||||||
absPath, err := rfs.abs(rfs.decryptPath(relPath))
|
absPath, err := rfs.abs(rfs.decryptPath(relPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -222,8 +236,7 @@ func (rfs *reverseFS) Access(relPath string, mode uint32, context *fuse.Context)
|
|||||||
|
|
||||||
// Open - FUSE call
|
// Open - FUSE call
|
||||||
func (rfs *reverseFS) Open(relPath string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
|
func (rfs *reverseFS) Open(relPath string, flags uint32, context *fuse.Context) (fuseFile nodefs.File, status fuse.Status) {
|
||||||
if relPath == configfile.ConfDefaultName {
|
if rfs.isTranslatedConfig(relPath) {
|
||||||
// gocryptfs.conf maps to .gocryptfs.reverse.conf in the plaintext directory
|
|
||||||
return rfs.loopbackfs.Open(configfile.ConfReverseName, flags, context)
|
return rfs.loopbackfs.Open(configfile.ConfReverseName, flags, context)
|
||||||
}
|
}
|
||||||
if rfs.isDirIV(relPath) {
|
if rfs.isDirIV(relPath) {
|
||||||
@ -232,9 +245,6 @@ func (rfs *reverseFS) Open(relPath string, flags uint32, context *fuse.Context)
|
|||||||
if rfs.isNameFile(relPath) {
|
if rfs.isNameFile(relPath) {
|
||||||
return rfs.newNameFile(relPath)
|
return rfs.newNameFile(relPath)
|
||||||
}
|
}
|
||||||
if rfs.isFiltered(relPath) {
|
|
||||||
return nil, fuse.EPERM
|
|
||||||
}
|
|
||||||
return rfs.NewFile(relPath, flags)
|
return rfs.NewFile(relPath, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +304,7 @@ func (rfs *reverseFS) OpenDir(cipherPath string, context *fuse.Context) ([]fuse.
|
|||||||
for i := range entries {
|
for i := range entries {
|
||||||
var cName string
|
var cName string
|
||||||
// ".gocryptfs.reverse.conf" in the root directory is mapped to "gocryptfs.conf"
|
// ".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
|
cName = configfile.ConfDefaultName
|
||||||
} else {
|
} else {
|
||||||
cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
|
cName = rfs.nameTransform.EncryptName(entries[i].Name, dirIV)
|
||||||
|
@ -85,7 +85,3 @@ func (rfs *reverseFS) decryptPath(relPath string) (string, error) {
|
|||||||
}
|
}
|
||||||
return filepath.Join(transformedParts...), nil
|
return filepath.Join(transformedParts...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rfs *reverseFS) isFiltered(relPath string) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user