go: x/crypto/ssh/terminal: ReadPassword does not support umlauts on Windows

What version of Go are you using (go version)?

go version go1.9.2 windows/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\development\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

What did you do?

Execute this on Gist on Windows (https://gist.github.com/levrik/99210259065679da20c3c66ef383eea9) and enter some umlauts in the password prompt (e.g. ö, ü or ä).

What did you expect to see?

image (Screenshot taken on go version go1.9.2 darwin/amd64)

What did you see instead?

pasted image at 2017_11_21 10_39 am

This was discovered when a colleague tried to use a new version of an internal command line tool and it didn’t accept the correct password anymore (password was supplied via command line flag before).

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

This should fix the issue.

diff --git a/ssh/terminal/util_windows.go b/ssh/terminal/util_windows.go
index 60979cc..e7dc952 100644
--- a/ssh/terminal/util_windows.go
+++ b/ssh/terminal/util_windows.go
@@ -17,6 +17,8 @@
 package terminal
 
 import (
+	"os"
+
 	"golang.org/x/sys/windows"
 )
 
@@ -98,5 +100,5 @@ func ReadPassword(fd int) ([]byte, error) {
 		windows.SetConsoleMode(windows.Handle(fd), old)
 	}()
 
-	return readPasswordLine(passwordReader(fd))
+	return readPasswordLine(os.NewFile(uintptr(fd), "sysfile"))
 }