Skip to content

Commit

Permalink
Merge pull request #95 from DBCDK/fix-askpass-signals
Browse files Browse the repository at this point in the history
ssh-askpass: ensure term restore before unclean exit
  • Loading branch information
srhb authored Dec 1, 2019
2 parents 9221e28 + 97cd1ed commit 3bade9f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,15 @@ func (sshCtx *SSHContext) CmdInteractive(host Host, timeout int, parts ...string

func askForSudoPassword() (string, error) {
fmt.Fprint(os.Stderr, "Please enter remote sudo password: ")
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
stdin := int(syscall.Stdin)
state, err := terminal.GetState(stdin)
if err != nil {
return "", err
}
utils.AddFinalizer(func() {
terminal.Restore(stdin, state)
})
bytePassword, err := terminal.ReadPassword(stdin)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 3bade9f

Please sign in to comment.