Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password input from terminal in Windows do not work #862

Closed
gjirm opened this issue Oct 8, 2021 · 1 comment · Fixed by #871
Closed

Password input from terminal in Windows do not work #862

gjirm opened this issue Oct 8, 2021 · 1 comment · Fixed by #871
Labels
bug Something isn't working

Comments

@gjirm
Copy link

gjirm commented Oct 8, 2021

Issue description

When launched, the application freezes and does not prompt user for a password.
This happens whenever entering password is expected from the user. For example these commands:

cosign generate-key-pair
cosign sign --key cosign.key ...

It works just fine when password is passed from stdin or from COSIGN_PASSWORD environment variable.

It seems that this is caused by golang.org/x/term module that is being used to read password from terminal, but this module does not support Windows. See module description:

"Package term provides support functions for dealing with terminals, as commonly found on UNIX systems. "

My environment

  • Windows 11 (21H2 - build 22000.194), Windows 10 (21H1 - build 19043.1237)
  • cosign v1.2.1
  • Windows Terminal 1.10.2714.0, native cmd.exe
@gjirm gjirm added the bug Something isn't working label Oct 8, 2021
@developer-guy
Copy link
Member

developer-guy commented Oct 11, 2021

@dlorenc I suggest using go-isatty package to solve the problem here because this package seems to support Windows too.

Or we can use the following one:

👉 https://stackoverflow.com/questions/22744443/check-if-there-is-something-to-read-on-stdin-in-golang

stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 {
    fmt.Println("data is being piped to stdin")
} else {
    fmt.Println("stdin is from a terminal")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants