summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-06-20 19:09:46 +0200
committerJakob Unterwurzacher2021-06-20 19:09:46 +0200
commitc5d8fa83ae702017fc90769dff178fda6a7942a3 (patch)
tree8f6593a3174a2d5240b4536a6248f25a871c5a7d /internal
parent203e65066fc1197427353eed3ae0a5108a1121ee (diff)
nametransform: pass badname patterns via New
This means we can unexport the field.
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/xattr_unit_test.go2
-rw-r--r--internal/nametransform/names.go18
2 files changed, 12 insertions, 8 deletions
diff --git a/internal/fusefrontend/xattr_unit_test.go b/internal/fusefrontend/xattr_unit_test.go
index a0cf4c8..c48781c 100644
--- a/internal/fusefrontend/xattr_unit_test.go
+++ b/internal/fusefrontend/xattr_unit_test.go
@@ -19,7 +19,7 @@ func newTestFS(args Args) *RootNode {
key := make([]byte, cryptocore.KeyLen)
cCore := cryptocore.New(key, cryptocore.BackendGoGCM, contentenc.DefaultIVBits, true, false)
cEnc := contentenc.New(cCore, contentenc.DefaultBS, false)
- n := nametransform.New(cCore.EMECipher, true, true)
+ n := nametransform.New(cCore.EMECipher, true, true, nil)
rn := NewRootNode(args, cEnc, n)
oneSec := time.Second
options := &fs.Options{
diff --git a/internal/nametransform/names.go b/internal/nametransform/names.go
index f730184..afc0f5d 100644
--- a/internal/nametransform/names.go
+++ b/internal/nametransform/names.go
@@ -44,19 +44,23 @@ type NameTransform struct {
// on the Raw64 feature flag
B64 *base64.Encoding
// Patterns to bypass decryption
- BadnamePatterns []string
+ badnamePatterns []string
}
// New returns a new NameTransform instance.
-func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
+func New(e *eme.EMECipher, longNames bool, raw64 bool, badname []string) *NameTransform {
+ tlog.Debug.Printf("nametransform.New: longNames=%v, raw64=%v, badname=%q",
+ longNames, raw64, badname)
+
b64 := base64.URLEncoding
if raw64 {
b64 = base64.RawURLEncoding
}
return &NameTransform{
- emeCipher: e,
- longNames: longNames,
- B64: b64,
+ emeCipher: e,
+ longNames: longNames,
+ B64: b64,
+ badnamePatterns: badname,
}
}
@@ -65,7 +69,7 @@ func New(e *eme.EMECipher, longNames bool, raw64 bool) *NameTransform {
func (n *NameTransform) DecryptName(cipherName string, iv []byte) (string, error) {
res, err := n.decryptName(cipherName, iv)
if err != nil {
- for _, pattern := range n.BadnamePatterns {
+ for _, pattern := range n.badnamePatterns {
match, err := filepath.Match(pattern, cipherName)
if err == nil && match { // Pattern should have been validated already
// Find longest decryptable substring
@@ -142,5 +146,5 @@ func (n *NameTransform) B64DecodeString(s string) ([]byte, error) {
// HaveBadnamePatterns returns true if BadName patterns were provided
func (n *NameTransform) HaveBadnamePatterns() bool {
- return len(n.BadnamePatterns) > 0
+ return len(n.badnamePatterns) > 0
}