diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2018-02-13 01:17:35 +0100 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2018-02-13 01:17:35 +0100 |
commit | c32d9bf24c3b670c3a56ea55aeefb6232f3d4ec8 (patch) | |
tree | f9891ff5b851d40c2f48c8e73e36e32197bfcc89 /vendor/golang.org/x/crypto/ssh/terminal/util_windows.go | |
parent | 886201867ac7383535c08d81dbabc6c9c77fe855 (diff) |
switch to subcommands
Diffstat (limited to 'vendor/golang.org/x/crypto/ssh/terminal/util_windows.go')
-rw-r--r-- | vendor/golang.org/x/crypto/ssh/terminal/util_windows.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go index 60979cc..4933ac3 100644 --- a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go +++ b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go @@ -17,6 +17,8 @@ package terminal import ( + "os" + "golang.org/x/sys/windows" ) @@ -71,13 +73,6 @@ func GetSize(fd int) (width, height int, err error) { return int(info.Size.X), int(info.Size.Y), nil } -// passwordReader is an io.Reader that reads from a specific Windows HANDLE. -type passwordReader int - -func (r passwordReader) Read(buf []byte) (int, error) { - return windows.Read(windows.Handle(r), buf) -} - // ReadPassword reads a line of input from a terminal without local echo. This // is commonly used for inputting passwords and other sensitive data. The slice // returned does not include the \n. @@ -98,5 +93,13 @@ func ReadPassword(fd int) ([]byte, error) { windows.SetConsoleMode(windows.Handle(fd), old) }() - return readPasswordLine(passwordReader(fd)) + var h windows.Handle + p, _ := windows.GetCurrentProcess() + if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil { + return nil, err + } + + f := os.NewFile(uintptr(h), "stdin") + defer f.Close() + return readPasswordLine(f) } |