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

x/crypto/ssh/terminal: ReadPassword keeps echo disabled when stopped with Ctrl+C #31180

Open
giner opened this issue Apr 1, 2019 · 8 comments
Open

Comments

@giner
Copy link

@giner giner commented Apr 1, 2019

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

$ go version
go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

Linux and macOS

What did you do?

Tried to use the following code to read passwords (from https://qiita.com/moutend/items/12d53750363edbbc3d6b):

package main
  
import (
    "fmt"
    "log"
    "syscall"

    "golang.org/x/crypto/ssh/terminal"
)

func main() {
    fmt.Print("Password: ")
    password, err := terminal.ReadPassword(int(syscall.Stdin))
    if err != nil {
        log.Fatal(err)
    } else {
        fmt.Printf("\nYour password is %v\n", string(password))
    }
}

What did you expect to see?

If I press Ctrl+C at the point when I'm supposed to enter password I'm expecting my terminal back working as before running the code.

What did you see instead?

I'm unable to see what I'm typing anymore as echo is kept disabled

@gopherbot gopherbot added this to the Unreleased milestone Apr 1, 2019
@andybons andybons changed the title x/crypto: teminal.ReadPassword keeps echo disabled when stopped with Ctrl+C x/crypto/ssh/terminal: ReadPassword keeps echo disabled when stopped with Ctrl+C Apr 1, 2019
@andybons
Copy link
Member

@andybons andybons commented Apr 1, 2019

Loading

@hanwen
Copy link
Contributor

@hanwen hanwen commented Apr 2, 2019

I thought this is normal behavior with other similar programs too.

Loading

@agnivade

This comment has been hidden.

@agnivade
Copy link
Contributor

@agnivade agnivade commented Apr 18, 2019

Doesn't seem to be the behavior for sudo su -

Loading

@giner
Copy link
Author

@giner giner commented Apr 18, 2019

Removed Linux from the description as I cannot reproduce it on Linux with go1.12.1.

Loading

@agnivade
Copy link
Contributor

@agnivade agnivade commented Apr 18, 2019

Actually, I can reproduce on Linux.

Loading

@giner
Copy link
Author

@giner giner commented Apr 18, 2019

It seems to depend on the shell. Cannot reproduce with bash (Ubuntu 18.04) but reproduced with dash.

Loading

@zladovan
Copy link

@zladovan zladovan commented Feb 15, 2020

I was able to reproduce with bash 5.0.11 on linux 4.19.99-1-MANJARO.

go version go1.13.7 linux/amd64

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants