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
This commit is contained in:
Sebastian Lackner 2017-12-12 14:38:00 +01:00 committed by rfjakob
parent ca594b2349
commit a24342f656
2 changed files with 24 additions and 1 deletions

View File

@ -550,7 +550,7 @@ func (fs *FS) Link(oldPath string, newPath string, context *fuse.Context) (code
} }
// Handle long file name // Handle long file name
cNewName := filepath.Base(cNewPath) cNewName := filepath.Base(cNewPath)
if nametransform.IsLongContent(cNewName) { if !fs.args.PlaintextNames && nametransform.IsLongContent(cNewName) {
dirfd, err := os.Open(filepath.Dir(cNewPath)) dirfd, err := os.Open(filepath.Dir(cNewPath))
if err != nil { if err != nil {
return fuse.ToStatus(err) return fuse.ToStatus(err)

View File

@ -812,3 +812,26 @@ func TestSymlink(t *testing.T) {
t.Fatal(err) 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)
}
}