summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Lackner2017-12-12 14:38:00 +0100
committerrfjakob2017-12-25 15:07:37 +0100
commita24342f656f6acd544ec07dada576d57a716b34d (patch)
treec63568499378bd673bbe7f64d8365183582e9164
parentca594b2349d748e410a6d834f0dd3d1a4a9cfa1c (diff)
fusefrontend: Handle PlaintextNames mode in Link
In PlaintextNames mode the "gocryptfs.longname." prefix does not have any special meaning. https://github.com/rfjakob/gocryptfs/issues/174
-rw-r--r--internal/fusefrontend/fs.go2
-rw-r--r--tests/matrix/matrix_test.go23
2 files changed, 24 insertions, 1 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index cc055c7..8c9e5e4 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -550,7 +550,7 @@ func (fs *FS) Link(oldPath string, newPath string, context *fuse.Context) (code
}
// Handle long file name
cNewName := filepath.Base(cNewPath)
- if nametransform.IsLongContent(cNewName) {
+ if !fs.args.PlaintextNames && nametransform.IsLongContent(cNewName) {
dirfd, err := os.Open(filepath.Dir(cNewPath))
if err != nil {
return fuse.ToStatus(err)
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 4194861..90cf55e 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -812,3 +812,26 @@ func TestSymlink(t *testing.T) {
t.Fatal(err)
}
}
+
+// Make sure the Link call works with paths starting with "gocryptfs.longname."
+func TestLink(t *testing.T) {
+ target := test_helpers.DefaultPlainDir + "/linktarget"
+ f, err := os.Create(target)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.Close()
+ path := test_helpers.DefaultPlainDir + "/gocryptfs.longname.XXX"
+ err = syscall.Link(target, path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = os.Remove(target)
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = os.Remove(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+}