Skip to content

Commit

Permalink
fusefrontend: Handle PlaintextNames mode in Unlink
Browse files Browse the repository at this point in the history
In PlaintextNames mode the "gocryptfs.longname." prefix does not have any
special meaning. We should not attempt to delete any .name files.

Partially fixes rfjakob#174
  • Loading branch information
slackner committed Nov 28, 2017
1 parent a74644e commit 3cb9744
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/fusefrontend/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) {
}

cName := filepath.Base(cPath)
if nametransform.IsLongContent(cName) {
if !fs.args.PlaintextNames && nametransform.IsLongContent(cName) {
var dirfd *os.File
dirfd, err = os.Open(filepath.Dir(cPath))
if err != nil {
Expand Down
17 changes: 17 additions & 0 deletions tests/matrix/matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,4 +794,21 @@ func TestMkfifo(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = os.Remove(path)
if err != nil {
t.Fatal(err)
}
}

// Make sure the Symlink call works with paths starting with "gocryptfs.longname."
func TestSymlink(t *testing.T) {
path := test_helpers.DefaultPlainDir + "/gocryptfs.longname.XXX"
err := syscall.Symlink("target", path)
if err != nil {
t.Fatal(err)
}
err = os.Remove(path)
if err != nil {
t.Fatal(err)
}
}

0 comments on commit 3cb9744

Please sign in to comment.