summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--tests/defaults/main_test.go3
-rw-r--r--tests/test_helpers/helpers.go2
7 files changed, 9 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
diff --git a/tests/defaults/main_test.go b/tests/defaults/main_test.go
index 8873f8f..e7e065e 100644
--- a/tests/defaults/main_test.go
+++ b/tests/defaults/main_test.go
@@ -18,6 +18,9 @@ import (
func TestMain(m *testing.M) {
test_helpers.ResetTmpDir(true)
+ // TestZerokey() in tests/cli verifies that mounting with `-zerokey` is equivalent
+ // to mounting with a config file with all-default options (just the masterkey
+ // set to all-zero).
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "-zerokey")
r := m.Run()
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index b98c0f7..5bc1298 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -141,6 +141,8 @@ func isExt4(path string) bool {
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
//
// It returns cipherdir without a trailing slash.
+//
+// If t is set, t.Fatal() is called on error, log.Panic() otherwise.
func InitFS(t *testing.T, extraArgs ...string) string {
prefix := "x."
if t != nil {