Skip to content

Commit

Permalink
util: password: Reverse the nonblocking stdin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
purpleidea committed Sep 30, 2023
1 parent 738485a commit ab7eb0a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion util/password/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ab7eb0a

Please sign in to comment.