summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-02-22 05:28:21 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2020-02-25 07:46:20 -0400
commit68c313911e8a3aed605a12398442212b99f41619 (patch)
treec4273c58fd0a675d02daef9a63bc6ce9c38e4c11 /vendor/golang.org/x/crypto/ssh/terminal/terminal.go
parent8a30759b6b7f73c76c90e0931e6cf1ca3d94ee61 (diff)
downloadpodman-68c313911e8a3aed605a12398442212b99f41619.tar.gz
podman-68c313911e8a3aed605a12398442212b99f41619.tar.bz2
podman-68c313911e8a3aed605a12398442212b99f41619.zip
Update vendor of buildah and containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/golang.org/x/crypto/ssh/terminal/terminal.go')
-rw-r--r--vendor/golang.org/x/crypto/ssh/terminal/terminal.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
index 2f04ee5b5..d1b4fca3a 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/terminal.go
@@ -7,6 +7,7 @@ package terminal
import (
"bytes"
"io"
+ "runtime"
"strconv"
"sync"
"unicode/utf8"
@@ -939,6 +940,8 @@ func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) {
// readPasswordLine reads from reader until it finds \n or io.EOF.
// The slice returned does not include the \n.
// readPasswordLine also ignores any \r it finds.
+// Windows uses \r as end of line. So, on Windows, readPasswordLine
+// reads until it finds \r and ignores any \n it finds during processing.
func readPasswordLine(reader io.Reader) ([]byte, error) {
var buf [1]byte
var ret []byte
@@ -947,10 +950,20 @@ func readPasswordLine(reader io.Reader) ([]byte, error) {
n, err := reader.Read(buf[:])
if n > 0 {
switch buf[0] {
+ case '\b':
+ if len(ret) > 0 {
+ ret = ret[:len(ret)-1]
+ }
case '\n':
- return ret, nil
+ if runtime.GOOS != "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \n
case '\r':
- // remove \r from passwords on Windows
+ if runtime.GOOS == "windows" {
+ return ret, nil
+ }
+ // otherwise ignore \r
default:
ret = append(ret, buf[0])
}