nametransform: delete NameTransformer interface
Useless layer of indirection.
This commit is contained in:
parent
e244b51491
commit
2efef1e270
@ -27,7 +27,7 @@ type RootNode struct {
|
|||||||
// states
|
// states
|
||||||
dirIVLock sync.RWMutex
|
dirIVLock sync.RWMutex
|
||||||
// Filename encryption helper
|
// Filename encryption helper
|
||||||
nameTransform nametransform.NameTransformer
|
nameTransform *nametransform.NameTransform
|
||||||
// Content encryption helper
|
// Content encryption helper
|
||||||
contentEnc *contentenc.ContentEnc
|
contentEnc *contentenc.ContentEnc
|
||||||
// This lock is used by openWriteOnlyFile() to block concurrent opens while
|
// This lock is used by openWriteOnlyFile() to block concurrent opens while
|
||||||
@ -54,7 +54,7 @@ type RootNode struct {
|
|||||||
inoMap inomap.TranslateStater
|
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 {
|
if args.SerializeReads {
|
||||||
serialize_reads.InitSerializer()
|
serialize_reads.InitSerializer()
|
||||||
}
|
}
|
||||||
|
@ -64,12 +64,3 @@ func TestShouldReturnFalseIfThereAreNoExclusions(t *testing.T) {
|
|||||||
t.Error("Should not exclude any path if no exclusions were specified")
|
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -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
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ type RootNode struct {
|
|||||||
// Stores configuration arguments
|
// Stores configuration arguments
|
||||||
args fusefrontend.Args
|
args fusefrontend.Args
|
||||||
// Filename encryption helper
|
// Filename encryption helper
|
||||||
nameTransform nametransform.NameTransformer
|
nameTransform *nametransform.NameTransform
|
||||||
// Content encryption helper
|
// Content encryption helper
|
||||||
contentEnc *contentenc.ContentEnc
|
contentEnc *contentenc.ContentEnc
|
||||||
// Tests whether a path is excluded (hidden) from the user. Used by -exclude.
|
// 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.
|
// NewRootNode returns an encrypted FUSE overlay filesystem.
|
||||||
// In this case (reverse mode) the backing directory is plain-text and
|
// In this case (reverse mode) the backing directory is plain-text and
|
||||||
// ReverseFS provides an encrypted view.
|
// 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{
|
rn := &RootNode{
|
||||||
args: args,
|
args: args,
|
||||||
nameTransform: n,
|
nameTransform: n,
|
||||||
|
@ -19,23 +19,6 @@ const (
|
|||||||
BadNameFlag = " GOCRYPTFS_BAD_NAME"
|
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.
|
// NameTransform is used to transform filenames.
|
||||||
type NameTransform struct {
|
type NameTransform struct {
|
||||||
emeCipher *eme.EMECipher
|
emeCipher *eme.EMECipher
|
||||||
|
@ -18,6 +18,9 @@ import (
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
test_helpers.ResetTmpDir(true)
|
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")
|
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "-zerokey")
|
||||||
r := m.Run()
|
r := m.Run()
|
||||||
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
||||||
|
@ -141,6 +141,8 @@ func isExt4(path string) bool {
|
|||||||
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
|
// gocryptfs -q -init -extpass "echo test" -scryptn=10 $extraArgs $cipherdir
|
||||||
//
|
//
|
||||||
// It returns cipherdir without a trailing slash.
|
// 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 {
|
func InitFS(t *testing.T, extraArgs ...string) string {
|
||||||
prefix := "x."
|
prefix := "x."
|
||||||
if t != nil {
|
if t != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user