Commit Graph

79 Commits

Author SHA1 Message Date
Tobias Klauser
f5beecf764 term: skip TestMakeRawState on GOOS=ios
Change-Id: I0068c03d571672db8f809e9308e438e7b030e075
Reviewed-on: https://go-review.googlesource.com/c/term/+/312250
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-22 11:46:43 +00:00
Tobias Klauser
b80969c673 term: add aix and zos build tags
Some packages depending on golang.org/x/term still need to build with
old Go versions and adding these build tags allows them build this
package with Go 1.11 and older.

Change-Id: I82d8c71120ff82d8ace07f96636f16c86edb15e5
Reviewed-on: https://go-review.googlesource.com/c/term/+/312249
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-21 21:04:24 +00:00
Tobias Klauser
72f3dc4e9b term: use existing unix implementation on solaris
All other unix platforms use the same implementation in term_unix.go.
The existing implementation in term_solaris.go is equivalent, so
use the common implementation on solaris as well.

Change-Id: Ie4f67fd3508bea54772c4422ff1dcf73ba76d985
Reviewed-on: https://go-review.googlesource.com/c/term/+/307669
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-06 21:00:42 +00:00
makeworld
de623e64d2 term: use stdin file descriptor in comment
Using a `fd` of `0` on Windows will crash with `panic: The handle is invalid.`
By getting the file descriptor from `os.Stdin`, this can be avoided.

Change-Id: Ie7915b1e0e1018fcb92b6ba006fe85a9aee439ad
GitHub-Last-Rev: 4e56574120
GitHub-Pull-Request: golang/term#3
Reviewed-on: https://go-review.googlesource.com/c/term/+/280232
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-03-17 15:32:31 +00:00
Russ Cox
6a3ed077a4 all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I39a1884031dd02279530c64cd5d65ddfb8ba299c
Reviewed-on: https://go-review.googlesource.com/c/term/+/294422
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-02-20 03:29:56 +00:00
Martin Tournoij
2321bbc49c Update doc to use "term" instead of "terminal"
Very small patch, but the example at the top still used the old
"terminal" package name, resulting in "golang.org/x/crypto/ssh/terminal"
being goimport'd instead of golang.org/x/term

Change-Id: If02a2d7ef6fe63fa86f98ca16b523d06ad897474
GitHub-Last-Rev: 594c1a04a1
GitHub-Pull-Request: golang/term#2
Reviewed-on: https://go-review.googlesource.com/c/term/+/276912
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-10 14:42:34 +00:00
Julie Qiu
ee85cb95a7 README.md: add badge to pkg.go.dev
Change-Id: I60b0ccc17038d457c105a0727139eb36d61b4e12
Reviewed-on: https://go-review.googlesource.com/c/term/+/275936
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-07 23:21:18 +00:00
Tobias Klauser
7de9c90e9d go.mod: update to latest golang.org/x/sys
This will add support for several newly added GOOS/GOARCH combinations,
e.g. netbsd/arm64.

Change-Id: I730be84e9067b3f6d0a3020d4a512975e227e718
Reviewed-on: https://go-review.googlesource.com/c/term/+/273347
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-26 16:20:22 +00:00
Filippo Valsorda
f5c789dd32 all: apply golang.org/wiki/TargetSpecific
Also removed the obsolete appengine tag, switched _unsupported.go to
negative tags, so that out-of-tree GOOSes compile out of the box,
reduced use of build tags to reduce confusion, and renamed files that
extend _unix.go to _unix_GOOS.go.

Updates #31044

Change-Id: Ifb6f14c99713bb6a9edff630f90e9beffff3ed02
Reviewed-on: https://go-review.googlesource.com/c/term/+/258002
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Andrea Barisani <lcars.net@gmail.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
2020-11-17 13:21:31 +00:00
Filippo Valsorda
d7a72108b8 all: import golang.org/x/crypto/ssh/terminal
This merges all code from x/crypto/ssh/terminal at commit
0c6587e931a935f573efb6988c8470cd8c0a58de with no refactoring,
simply mapping util_* files to term_*.

The x/crypto history for the merge was rewritten with

    git filter-repo --path ssh/terminal/ --path-rename ssh/terminal/:

and then stitched together with "git replace --graft".

The merge preserves git blame visibility.

Updates #31044

Change-Id: Ic51fc8ec20b3a384cdd8868fde06fe69b6317695
2020-11-14 00:47:01 +01:00
Mahdi Hosseini Moghaddam
c955d0b553 ssh/terminal: add support for zos
Fixes golang/go#42496

Change-Id: Iae2ddb916904d9b3947bec9638c9fbf892df7b7c
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/269177
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-11-12 15:50:50 +00:00
Hana (Hyang-Ah) Kim
07bee379ff ssh/terminal: handle ctrl+C, ctrl+F, ctrl+B
ctrl+C: terminate readline, which may result in application termination.
ctrl+F: keyRight
ctrl+B: keyLeft

Update golang/go#27147

Change-Id: If319ef79708b98c030cbce102400a785d15137f8
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/228223
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-14 15:58:20 +00:00
Alex Brainman
1a268e5305 ssh/terminal: adjust ReadConsole rules on windows
CL 212377 changed end of input character on windows - from \n to \r.
But CL 212377 did not adjust ReadConsole accordingly. For example,
after CL 212377 \n was still used to end of password processing,
and \r was ignored.

This CL swaps these rules - \r is now used to end password processing,
and \n are ignored. The change only affects windows, all non windows
code should work as before.

This CL also adjusts TestReadPasswordLineEnd to fit new rules.

Fixes golang/go#36609

Change-Id: I027bf80d10e7d4d4b17ff0264935d14b8bea9097
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/215417
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-02-08 06:05:01 +00:00
Yasuhiro Matsumoto
31072773c2 ssh/terminal: stop using ENABLE_LINE_INPUT
ReadConsole does not read more than 254 bytes when ENABLE_LINE_INPUT is
enabled.

Fixes golang/go#36071

Change-Id: If5c160404b855387a80f1d57638aac3f2db1a097
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/212377
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-01-15 08:54:10 +00:00
Tobias Klauser
ad39bd3f04 term: go mod tidy
Change-Id: If7fce055ae4d5b3aabdae161da42bd8b74de074c
Reviewed-on: https://go-review.googlesource.com/c/term/+/206159
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-10 17:16:34 +00:00
Dmitri Goutnik
761de043ff term: fix build on freebsd/arm64
Updates golang/go#35182

Change-Id: Ie108dbc04e97d9e120f64686fbf7fe1d51d7de5f
Reviewed-on: https://go-review.googlesource.com/c/term/+/203617
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-26 14:42:23 +00:00
Tobias Klauser
5215a04f73 term: fix build on solaris
These build tags were copied by mistake to term_solaris.go. Remove them
to fix the build on solaris.

Change-Id: I0d6c4a1bd3a9dcbb9973051cff93819ba28f1fa8
Reviewed-on: https://go-review.googlesource.com/c/term/+/201418
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-16 17:40:38 +00:00
Tobias Klauser
159e5304a9 term: use pseudo terminal in TestIsTerminalTerm on linux
Use /dev/ptmx to create a new pseudo terminal and use this in
TestIsTerminalTerm.

This should fix the test failing with ENXIO on some linux builders.

Change-Id: I39880d2cb538e3e9c8063ac79b5380ed00a476f5
Reviewed-on: https://go-review.googlesource.com/c/term/+/201417
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-16 17:06:09 +00:00
Tobias Klauser
f887077f25 term: fix build on js/wasm and nacl
Change-Id: I8ff21952a72f3f5838c9959f00d9f4c8b4b45d2d
Reviewed-on: https://go-review.googlesource.com/c/term/+/201117
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-14 20:57:23 +00:00
Tobias Klauser
c3296ef303 term: add IsTerminal function
Extracted from golang.org/x/crypto/ssh/terminal

The implementation for plan9 is based on IsTerminal from
github.com/mattn/go-isatty

Change-Id: Id7bf2d6595639ff08e5fd5f786a145d340bbed08
Reviewed-on: https://go-review.googlesource.com/c/term/+/200681
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-14 20:34:36 +00:00
Brad Fitzpatrick
24acb349b8 Revert "ssh/terminal: account for win32 api changes"
This reverts commit CL 196897 (commit cf60e62b0d)

Reason for revert: we're reverting the API change instead
in https://go-review.googlesource.com/c/sys/+/197597

Change-Id: I41741c85bb7a07b9ce13264ebb26ee3f968772fa
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/197598
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
2019-09-26 18:03:35 +00:00
Jason A. Donenfeld
cf60e62b0d ssh/terminal: account for win32 api changes
The API changed for this function, since the call always succeeds.
Update this user of it accordingly.

Fixes: golang/go#34461

Change-Id: I9d19b70767fc6b1b9292ad8732dd8e54bb6a8ae0
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/196897
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-23 03:51:54 +00:00
Andrey Petrov
c5b4c79d1f ssh/terminal: Use move-N sequences for >1 cursor moves
Before, we emitted N single-move sequences on a cursor move. For
example, "move 4 left" would emit "^[[D^[[D^[[D^[[D". With this change,
it would emit "^[[4D".

Using variable move sequences when possible reduces the amount of
rendering output that the terminal implementation produces. This can
have some low-level performance benefits, but also helps consumers
reason through the produced output.

Includes a test with a couple of cases.

Note: The old implementation used ^[[D instead of ^[D which is also
valid. This is true in several unrelated places, so this implementation
continues to use ^[[D for consistency.

Change-Id: If38eaaed8fb4075499fdda54c06681dc34c3ad70
GitHub-Last-Rev: 92ef2538d33a9493f3df09984c277dfd8bf0abf4
GitHub-Pull-Request: golang/crypto#82
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/169077
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-25 15:42:30 +00:00
Bryan C. Mills
4b5627afda all: add go.mod
Commands run:
	go mod init
	go mod edit -go=1.11
	go mod tidy
	go list -m all
	go test ./...

Updates golang/go#30228

Change-Id: I86819ac0a2704468903e34ca49308ce65149791b
Reviewed-on: https://go-review.googlesource.com/c/term/+/167160
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-12 20:22:59 +00:00
Max Semenik
3fba1d1f88 ssh/terminal: fix GetSize on Windows
Return window size instead of buffer size.

Fixes golang/go#27743

Change-Id: Ib1cd249f5680d86d505032e51d9102c2718ddf6f
Reviewed-on: https://go-review.googlesource.com/c/163538
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-28 05:08:51 +00:00
Michal Bohuslávek
1fb3bd0768 ssh/terminal: support ^N and ^P
This makes it possible to navigate the history without leaving
the home row on the keyboard.

Change-Id: Id24c43f8eb6090520ab37bf8126264901b70c489
Reviewed-on: https://go-review.googlesource.com/c/33618
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-28 19:33:16 +00:00
Tobias Klauser
5c4920f7cd ssh/terminal: enable tests for aix
Enable the tests on aix after support was added in CL 151077.

Change-Id: I2dcdaaa54d7c27b7697224e0f3cfab3cf0b52b6a
Reviewed-on: https://go-review.googlesource.com/c/151437
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Clément Chigot <clement.chigot@atos.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-27 14:34:15 +00:00
Tobias Klauser
47e6c8196c ssh/terminal: use "reports whether" in IsTerminal doc
Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns true if")

Change-Id: I6972d123ba99bbf3dbf95e876b45b2ecd98dd07c
Reviewed-on: https://go-review.googlesource.com/c/151257
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-26 16:34:21 +00:00
chigotc
9b51863744 ssh/terminal: add AIX operating system
This commit adds AIX operation system to ssh/terminal package.

Change-Id: I31ccec5512dbf476eaf22ff79951b5fab434d5fd
Reviewed-on: https://go-review.googlesource.com/c/151077
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-11-26 09:39:34 +00:00
Tobias Klauser
2f5b78d13e ssh/terminal: fix TestMakeRawState on iOS
Fix the following failure on iOS:

--- FAIL: TestMakeRawState (0.00s)
	terminal_test.go:332: failed to get terminal state from MakeRaw: operation not permitted

Updates golang/go#25535

Change-Id: I1ab6feb31ba5e89dc0d5f2a1cefd56c09f178e80
Reviewed-on: https://go-review.googlesource.com/114415
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-24 12:53:53 +00:00
Hana (Hyang-Ah) Kim
c0053fbbb3 ssh/terminal: run tests only on supported platforms
The tag matches the platforms defined in util*.go
where the most tested logic is defined.

Change-Id: I90f67d988c795738c3effbc8554a933a7cb355d2
Reviewed-on: https://go-review.googlesource.com/112555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-09 20:57:47 +00:00
Andrew Bonventre
05bb8bb4be CONTRIBUTING.md: remove note about not accepting Pull Requests
Updates golang/go#24185

Change-Id: I582f013c13651c71d6fdf48be3b5e8ddf0341e80
Reviewed-on: https://go-review.googlesource.com/100694
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-14 18:02:04 +00:00
Tobias Klauser
7d04dfe72d ssh/terminal: store termios copy in terminal state on Solaris
TestMakeRawState currently fails on Solaris:

  --- FAIL: TestMakeRawState (0.00s)
          terminal_test.go:334: states do not match; was &{0xc420015dd0}, expected &{0xc420015da0}

Change terminal.State to include a copy to the unix.Termios (like the
implementation for Linux and the BSDs) which also makes terminal.MakeRaw behave
as expected and lets TestMakeRawState pass.

Change-Id: I29382f83b84ff301991e1db170f32f41e144aec8
Reviewed-on: https://go-review.googlesource.com/99456
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-08 17:26:49 +00:00
Tobias Klauser
f9bf865cb0 ssh/terminal: simplify defer
Directly use unix.IoctlSetTermios and windows.SetConsoleMode instead of
wrapping them with a closure.

Change-Id: I6309253fbb6e59e029424273b48aaa608873ea17
Reviewed-on: https://go-review.googlesource.com/99455
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-08 17:19:52 +00:00
Yasuhiro Matsumoto
189f313d0c ssh/terminal: use duplicate handle in ReadPassword
os.NewFile assigns finalizer to close file handle
passed into ReadPassword. But that is not expected.
Make a duplicate of original file handle, and pass
copy handle into ReadPassword instead.

Fixes golang/go#23525

Change-Id: I4d6725e9a1cc20defd1b58afc383e35a7f9ee4e9
Reviewed-on: https://go-review.googlesource.com/89395
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-26 02:30:34 +00:00
Kevin Burke
f344d0325d all: fix errors reported by vet, golint
None are "wrong" per se, but there are a lot of good suggestions and
in one case a docstring that was not present in godoc due to the
presence of an extra newline.

Changed "Id" in struct properties to "ID" in some non-exported
structs. Removed a trailing period from some error messages; I believe
the exact contents of error strings are not covered by the Go
compatibility promise.

Change-Id: I7c620582dc247396f72c52d38c909ccc0ec87b83
Reviewed-on: https://go-review.googlesource.com/80145
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-28 17:48:09 +00:00
Yasuhiro Matsumoto
a21c5dde4c ssh/terminal: handle non-ASCII characters when reading passwords
ReadPassword uses Windows ReadFile to read from console handle.
But ReadFile does not split input into UTF-8 characters, so ReadFile
only works when input is ASCII. Use os.File instead of Windows
ReadFile, because os.File reads console and parses it into UTF-8.

Fixes golang/go#22828

Change-Id: Ifeed3e8048b51f46706c28d4154a3e4b10111a3e
Reviewed-on: https://go-review.googlesource.com/79335
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-24 09:08:02 +00:00
Tobias Klauser
a1a083ff5a terminal/ssh: use ioctl wrappers from x/sys/unix
Use the ioctl wrapper functions from x/sys/unix instead of manually
re-implementing them.

Change-Id: I224de0c6ec7439dfd8c45c72071c947be8813d6a
Reviewed-on: https://go-review.googlesource.com/75991
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-06 16:30:40 +00:00
Kevin Burke
aa45bf8df0 README: add links to useful resources
Move the README to README.md so Gerrit can render it; currently
Gerrit only renders files named exactly "README.md" (for example at
https://go.googlesource.com/go).

Add more links to the README explaining how to file issues,
how to submit code changes, where to download the code to and
how to get it. Hopefully this should help people who go to
https://go.googlesource.com/term or https://github.com/golang/term
figure out how to get started with development.

Change-Id: I8e1b1f1204f4c80acc5fd2cd28ab2efe4403c015
Reviewed-on: https://go-review.googlesource.com/49890
Reviewed-by: Kevin Burke <kev@inburke.com>
2017-09-27 05:45:33 +00:00
Tobias Klauser
5cd87de7cc ssh/terminal: set termios VMIN and VTIME in MakeRaw
The Solaris version of MakeRaw already sets VMIN and VTIME explicitly
such that a read returns when one character is available.
cfmakeraw (whose behavior MakeRaw replicate) in glibc and the BSD's libc
also set these values explicitly, so it should be done in the Linux/BSD
versions of MakeRaw as well to be consistent.

Change-Id: I531641ec87fd6a21b7a544b9a464bb90045b0bb1
Reviewed-on: https://go-review.googlesource.com/53570
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-18 13:51:34 +00:00
Tobias Klauser
073b14d8cc ssh/terminal: use console functions, types and consts from x/sys/windows
Use GetConsoleMode, SetConsoleMode and GetConsoleScreenBufferInfo and
the corresponding types and constants from golang.org/x/sys/windows
instead of locally defining them.

Change-Id: I69292a47114d071be261ffda6ca620a0b9820d00
Reviewed-on: https://go-review.googlesource.com/52990
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-08-04 07:50:21 +00:00
Tobias Klauser
d45e3a0228 ssh/terminal: use termios ioctl read/write constants from x/sys/unix
Use the TCGETS/TCSETS and TIOCGETA/TIOCSETA definitions from x/sys/unix
instead of manually declaring them or using the corresponding
definitions from syscall.

Change-Id: I37c2c8124d251eb47467b4184a7cc39781775f11
Reviewed-on: https://go-review.googlesource.com/51690
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-28 18:30:02 +00:00
Rick Sayre
9d2f68fd6d ssh/terminal: implement missing functions for Solaris/OmniOS
terminal.MakeRaw
    terminal.Restore
    terminal.GetState
    terminal.GetSize

Fixes golang/go#20062

Change-Id: I9ccf194215998c5b80dbedc4f248b481f0ca57a6
Reviewed-on: https://go-review.googlesource.com/41297
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-21 04:31:20 +00:00
Adam Langley
efcab1a52e ssh/terminal: consume data before checking for an error.
According to the io.Reader docs, Alex had it right the first time. (See
discussion on https://golang.org/cl/25355.)

Change-Id: Ib6fb9dfb99009e034263574e82d7e9d4828df38f
Reviewed-on: https://go-review.googlesource.com/35242
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
2017-01-17 00:48:27 +00:00
Alex Brainman
038bd0bb6d ssh/terminal: fix line endings handling in ReadPassword
Fixes golang/go#16552

Change-Id: I18a9c9b42fe042c4871b3efb3f51bef7cca335d0
Reviewed-on: https://go-review.googlesource.com/25355
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: Adam Langley <agl@golang.org>
2017-01-16 17:16:45 +00:00
Peter Morjan
a5e02a7a6f ssh/terminal: consistent return value for Restore
This patch makes the Restore function return nil
on success to be consistent with other functions
like MakeRaw.

Change-Id: I81e63f568787dd88466a5bb30cb87c4c3be75a5c
Reviewed-on: https://go-review.googlesource.com/34952
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-07 18:00:30 +00:00
Joe Tsai
3acf1ca968 all: fix some vet warnings
Change-Id: I85c2912a6862c6c251450f2a0926ecd33a9fb8e7
Reviewed-on: https://go-review.googlesource.com/34815
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-01-04 23:09:04 +00:00
Mikio Hara
426ef97d77 ssh/terminal: fix a typo
Change-Id: Iafe2ebb6d37afd2a64aa72750a722d4860bb735e
Reviewed-on: https://go-review.googlesource.com/34535
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-19 06:01:35 +00:00
Adam Langley
3ea8c23763 x/crypto/ssh/terminal: replace \n with \r\n.
18e6eb769a made MakeRaw match C's behaviour. This included clearing the
OPOST flag, which means that one now needs to write \r\n for a newline,
otherwise the cursor doesn't move back to the beginning and the terminal
prints a staircase.

(Dear god, we're still emulating line printers.)

This change causes the terminal package to do the required
transformation.

Fixes golang/go#17364.

Change-Id: Ida15d3cf701a21eaa59161ab61b3ed4dee2ded46
Reviewed-on: https://go-review.googlesource.com/33902
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-07 22:17:40 +00:00
Fazal Majid
d7ffdd5ca2 ssh/terminal: implement ReadPassword and IsTerminal
Fixes golang/go#13085.

Change-Id: I2fcdd60e5e8db032d6fa3ce76198bdc7a63f3cf6
Reviewed-on: https://go-review.googlesource.com/16722
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-03 20:04:50 +00:00