Skip to content

Commit

Permalink
x/crypto/ssh/terminal: have MakeRaw mirror cfmakeraw.
Browse files Browse the repository at this point in the history
Rather than guessing at which terminal flags should be set or cleared by
MakeRaw, this change tries to make it mirror the behaviour documented
for cfmakeraw() in the termios(3) manpage.

Fixes #15625

Change-Id: Icd6b18ffb57ea332147c8c9b25eac5e41eb0863a
Reviewed-on: https://go-review.googlesource.com/22964
Run-TryBot: Adam Langley <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Faiyaz Ahmed <[email protected]>
Reviewed-by: Adam Langley <[email protected]>
  • Loading branch information
fdawg4l authored and agl committed Jul 18, 2016
1 parent f28b564 commit 911fafb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ssh/terminal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ func MakeRaw(fd int) (*State, error) {
}

newState := oldState.termios
newState.Iflag &^= syscall.ISTRIP | syscall.INLCR | syscall.ICRNL | syscall.IGNCR | syscall.IXON | syscall.IXOFF
newState.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.ISIG
// This attempts to replicate the behaviour documented for cfmakeraw in
// the termios(3) manpage.
newState.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
newState.Oflag &^= syscall.OPOST
newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
newState.Cflag &^= syscall.CSIZE | syscall.PARENB
newState.Cflag |= syscall.CS8
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
return nil, err
}
Expand Down

0 comments on commit 911fafb

Please sign in to comment.