From ab7eb0a293dbd79744c41508518033032c0019dc Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 29 Sep 2023 22:13:14 -0400 Subject: [PATCH] util: password: Reverse the nonblocking stdin It's not clear if this is absolutely necessary or not, but it probably doesn't hurt. It's not clear if there is a way to read the previous state before running this. Of course this isn't really thread-safe, so use at your own risk. --- util/password/password.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/password/password.go b/util/password/password.go index e12a1ffa..00cdfa31 100644 --- a/util/password/password.go +++ b/util/password/password.go @@ -69,7 +69,8 @@ func ReadPasswordCtxFdPrompt(ctx context.Context, fd int, prompt string) ([]byte if err := syscall.SetNonblock(fd, true); err != nil { return nil, err } - file := os.NewFile(uintptr(fd), "") // XXX: name? + defer syscall.SetNonblock(fd, false) // TODO: is this necessary? + file := os.NewFile(uintptr(fd), "") // XXX: name? // We do some term magic to not print the password. This is taken from: // golang.org/x/term/term_unix.go:readPassword