From dc21cd357258df775e67a36cbcd70fc5f83543ad Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 25 Jan 2020 16:54:57 +0100 Subject: [PATCH] tests: cli: add TestSymlinkedCipherdir https://github.com/rfjakob/gocryptfs/issues/450 --- tests/cli/cli_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 423afdf..3e1bf42 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -609,3 +609,38 @@ func TestNotIdle(t *testing.T) { // All good. test_helpers.UnmountPanic(mnt) } + +// TestSymlinkedCipherdir checks that if CIPHERDIR itself is a symlink, it is +// followed. +// https://github.com/rfjakob/gocryptfs/issues/450 +func TestSymlinkedCipherdir(t *testing.T) { + dir := test_helpers.InitFS(t) + dirSymlink := dir + ".symlink" + err := os.Symlink(dir, dirSymlink) + if err != nil { + t.Fatal(err) + } + mnt := dir + ".mnt" + test_helpers.MountOrFatal(t, dirSymlink, mnt, "-extpass=echo test") + defer test_helpers.UnmountPanic(mnt) + + file := mnt + "/file" + f, err := os.Create(file) + if err != nil { + t.Fatal(err) + } + f.Close() + + f, err = os.Open(mnt) + if err != nil { + t.Fatal(err) + } + defer f.Close() + names, err := f.Readdirnames(0) + if err != nil { + t.Fatal(err) + } + if len(names) != 1 || names[0] != "file" { + t.Errorf("wrong Readdirnames result: %v", names) + } +}