From ca24c206945266d6397aa0e7d136d5bdcbda777f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 8 Sep 2018 13:04:33 +0200 Subject: main: don't read the config file twice (fix pipe bug) Instead, first Load() the file, then DecryptMasterKey(). Fixes https://github.com/rfjakob/gocryptfs/issues/258 --- tests/cli/cli_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/cli') diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index eaa92b6..bd22a43 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -495,3 +495,26 @@ func TestExcludeForward(t *testing.T) { } t.Log(err) } + +// Check that the config file can be read from a named pipe. +// Make sure bug https://github.com/rfjakob/gocryptfs/issues/258 does not come +// back. +func TestConfigPipe(t *testing.T) { + dir := test_helpers.InitFS(t) + mnt := dir + ".mnt" + err := os.Mkdir(mnt, 0700) + if err != nil { + t.Fatal(err) + } + bashLine := fmt.Sprintf("%s -q -extpass \"echo test\" -config <(cat %s/gocryptfs.conf) %s %s", test_helpers.GocryptfsBinary, dir, dir, mnt) + cmd := exec.Command("bash", "-c", bashLine) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stdout + err = cmd.Run() + exitCode := test_helpers.ExtractCmdExitCode(err) + if exitCode != 0 { + t.Errorf("bash command\n%q\nresulted in exit code %d", bashLine, exitCode) + return + } + test_helpers.UnmountPanic(mnt) +} -- cgit v1.2.3