aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/root_node.go4
-rw-r--r--internal/fusefrontend_reverse/excluder_test.go9
-rw-r--r--internal/fusefrontend_reverse/mocks_test.go32
-rw-r--r--internal/fusefrontend_reverse/root_node.go4
-rw-r--r--internal/nametransform/names.go17
5 files changed, 4 insertions, 62 deletions
diff --git a/internal/fusefrontend/root_node.go b/internal/fusefrontend/root_node.go
index 35b7be0..af4407e 100644
--- a/internal/fusefrontend/root_node.go
+++ b/internal/fusefrontend/root_node.go
@@ -27,7 +27,7 @@ type RootNode struct {
// states
dirIVLock sync.RWMutex
// Filename encryption helper
- nameTransform nametransform.NameTransformer
+ nameTransform *nametransform.NameTransform
// Content encryption helper
contentEnc *contentenc.ContentEnc
// This lock is used by openWriteOnlyFile() to block concurrent opens while
@@ -54,7 +54,7 @@ type RootNode struct {
inoMap inomap.TranslateStater
}
-func NewRootNode(args Args, c *contentenc.ContentEnc, n nametransform.NameTransformer) *RootNode {
+func NewRootNode(args Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode {
if args.SerializeReads {
serialize_reads.InitSerializer()
}
diff --git a/internal/fusefrontend_reverse/excluder_test.go b/internal/fusefrontend_reverse/excluder_test.go
index d6cfef3..e44c0e0 100644
--- a/internal/fusefrontend_reverse/excluder_test.go
+++ b/internal/fusefrontend_reverse/excluder_test.go
@@ -64,12 +64,3 @@ func TestShouldReturnFalseIfThereAreNoExclusions(t *testing.T) {
t.Error("Should not exclude any path if no exclusions were specified")
}
}
-
-func TestShouldCallIgnoreParserToCheckExclusion(t *testing.T) {
- rfs, ignorerMock := createRFSWithMocks()
-
- rfs.isExcludedPlain("some/path")
- if ignorerMock.calledWith != "some/path" {
- t.Error("Failed to call IgnoreParser")
- }
-}
diff --git a/internal/fusefrontend_reverse/mocks_test.go b/internal/fusefrontend_reverse/mocks_test.go
deleted file mode 100644
index 2d14c1d..0000000
--- a/internal/fusefrontend_reverse/mocks_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package fusefrontend_reverse
-
-import (
- "github.com/rfjakob/gocryptfs/internal/nametransform"
-)
-
-type IgnoreParserMock struct {
- toExclude string
- calledWith string
-}
-
-func (parser *IgnoreParserMock) MatchesPath(f string) bool {
- parser.calledWith = f
- return f == parser.toExclude
-}
-
-type NameTransformMock struct {
- nametransform.NameTransform
-}
-
-func (n *NameTransformMock) DecryptName(cipherName string, iv []byte) (string, error) {
- return "mockdecrypt_" + cipherName, nil
-}
-
-func createRFSWithMocks() (*RootNode, *IgnoreParserMock) {
- ignorerMock := &IgnoreParserMock{}
- nameTransformMock := &NameTransformMock{}
- var rfs RootNode
- rfs.excluder = ignorerMock
- rfs.nameTransform = nameTransformMock
- return &rfs, ignorerMock
-}
diff --git a/internal/fusefrontend_reverse/root_node.go b/internal/fusefrontend_reverse/root_node.go
index 10b0d69..b072f85 100644
--- a/internal/fusefrontend_reverse/root_node.go
+++ b/internal/fusefrontend_reverse/root_node.go
@@ -28,7 +28,7 @@ type RootNode struct {
// Stores configuration arguments
args fusefrontend.Args
// Filename encryption helper
- nameTransform nametransform.NameTransformer
+ nameTransform *nametransform.NameTransform
// Content encryption helper
contentEnc *contentenc.ContentEnc
// Tests whether a path is excluded (hidden) from the user. Used by -exclude.
@@ -41,7 +41,7 @@ type RootNode struct {
// NewRootNode returns an encrypted FUSE overlay filesystem.
// In this case (reverse mode) the backing directory is plain-text and
// ReverseFS provides an encrypted view.
-func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n nametransform.NameTransformer) *RootNode {
+func NewRootNode(args fusefrontend.Args, c *contentenc.ContentEnc, n *nametransform.NameTransform) *RootNode {
rn := &RootNode{
args: args,
nameTransform: n,
diff --git a/internal/nametransform/names.go b/internal/nametransform/names.go
index afc0f5d..2ee52e4 100644
--- a/internal/nametransform/names.go
+++ b/internal/nametransform/names.go
@@ -19,23 +19,6 @@ const (
BadNameFlag = " GOCRYPTFS_BAD_NAME"
)
-// NameTransformer is an interface used to transform filenames.
-type NameTransformer interface {
- DecryptName(cipherName string, iv []byte) (string, error)
- EncryptName(plainName string, iv []byte) (string, error)
- EncryptAndHashName(name string, iv []byte) (string, error)
- EncryptAndHashBadName(name string, iv []byte, dirfd int) (string, error)
- // HashLongName - take the hash of a long string "name" and return
- // "gocryptfs.longname.[sha256]"
- //
- // This function does not do any I/O.
- HashLongName(name string) string
- HaveBadnamePatterns() bool
- WriteLongNameAt(dirfd int, hashName string, plainName string) error
- B64EncodeToString(src []byte) string
- B64DecodeString(s string) ([]byte, error)
-}
-
// NameTransform is used to transform filenames.
type NameTransform struct {
emeCipher *eme.EMECipher