diff options
author | Jakob Unterwurzacher | 2019-04-08 20:18:45 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-04-08 20:18:45 +0200 |
commit | fe06e9f45646893dc88ebe9e657e2e991f6f5fbb (patch) | |
tree | ad5d8e2910ed71a5c579e40f897093bec2e19011 /internal | |
parent | 8459bb15c1a32561c250a8b688ab4a7ecda0a4aa (diff) |
readpassword: delete CheckTrailingGarbage
CheckTrailingGarbage was called even when "-passfile" was
used, which is stupid, and causes false positives:
https://github.com/rfjakob/gocryptfs/issues/391
(false error "Received trailing garbage after the password"
when using -passfile in .bash_profile)
Instead of trying to improve the logic to handle that case
and make everything even more complicated, delete the function.
It is unclear if actually helps in some cases, and it definitely
harms as shown by the above bug report.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/fusefrontend_reverse/reverse_longnames.go | 2 | ||||
-rw-r--r-- | internal/readpassword/read.go | 32 |
2 files changed, 1 insertions, 33 deletions
diff --git a/internal/fusefrontend_reverse/reverse_longnames.go b/internal/fusefrontend_reverse/reverse_longnames.go index 9f044e8..f07e413 100644 --- a/internal/fusefrontend_reverse/reverse_longnames.go +++ b/internal/fusefrontend_reverse/reverse_longnames.go @@ -105,7 +105,7 @@ func (rfs *ReverseFS) findLongnameParent(dir string, dirIV []byte, longname stri } func (rfs *ReverseFS) newNameFile(relPath string) (nodefs.File, fuse.Status) { - dotName := filepath.Base(relPath) // gocryptfs.longname.XYZ.name + dotName := filepath.Base(relPath) // gocryptfs.longname.XYZ.name longname := nametransform.RemoveLongNameSuffix(dotName) // gocryptfs.longname.XYZ // cipher directory cDir := nametransform.Dir(relPath) diff --git a/internal/readpassword/read.go b/internal/readpassword/read.go index 060100b..92a0886 100644 --- a/internal/readpassword/read.go +++ b/internal/readpassword/read.go @@ -8,8 +8,6 @@ import ( "os" "os/exec" "strings" - "sync" - "time" "golang.org/x/crypto/ssh/terminal" @@ -159,33 +157,3 @@ func readLineUnbuffered(r io.Reader) (l []byte) { l = append(l, b...) } } - -// CheckTrailingGarbage tries to read one byte from stdin and exits with a -// fatal error if the read returns any data. -// This is meant to be called after reading the password, when there is no more -// data expected. This helps to catch problems with third-party tools that -// interface with gocryptfs. -// -// This is tested via TestInitTrailingGarbage() in tests/cli/cli_test.go. -func CheckTrailingGarbage() { - if terminal.IsTerminal(int(os.Stdin.Fd())) { - // Be lenient when interacting with a human. - return - } - var wg sync.WaitGroup - wg.Add(1) - go func() { - b := make([]byte, 1) - wg.Done() - n, _ := os.Stdin.Read(b) - if n > 0 { - tlog.Fatal.Printf("Received trailing garbage after the password") - os.Exit(exitcodes.ReadPassword) - } - }() - // Wait for the goroutine to start up plus one millisecond for the read to - // return. If there is data available, this SHOULD be plenty of time to - // read one byte. However, I don't see a way to be sure. - wg.Wait() - time.Sleep(1 * time.Millisecond) -} |