94 Commits

Author SHA1 Message Date
Gopher Robot
1efcd90d86 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: I3ff1efa287de001f5b080fc389a03231a6102ce3
Reviewed-on: https://go-review.googlesource.com/c/term/+/460496
Run-TryBot: Gopher Robot <gobot@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
v0.4.0
2023-01-04 15:40:46 +00:00
Gopher Robot
97ca0e3821 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: I3c770ec1f36cd379ef7400445cf05e32afb1e109
Reviewed-on: https://go-review.googlesource.com/c/term/+/455296
Run-TryBot: Gopher Robot <gobot@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.3.0
2022-12-05 21:31:52 +00:00
Gopher Robot
f72a2d8d64 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: I881b6b77e89e8d521940c996e893be72632b4867
Reviewed-on: https://go-review.googlesource.com/c/term/+/448456
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Gopher Robot <gobot@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
v0.2.0
2022-11-07 19:53:28 +00:00
M. J. Fromberger
f6f2839df8 term: remove unused variable
The eraseUnderCursor variable is unused, it came in with the import
of the x/crypto/ssh/terminal package at d7a7210 but is not referenced
here.

When this package is vendored, the unused unexported name trips warnings
from tools like staticcheck.

Change-Id: I4289239edcdfec434ec26b164ae6c0a9b9ee7067
GitHub-Last-Rev: a4ab5868b4
GitHub-Pull-Request: golang/term#10
Reviewed-on: https://go-review.googlesource.com/c/term/+/446455
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-02 18:10:37 +00:00
Gopher Robot
8365914569 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.
Once this CL is submitted, and post-submit testing succeeds on all
first-class ports across all supported Go versions, this repository
will be tagged with its next minor version.

Change-Id: I481d3392e3d112911300c7bcf9411df0c6b73bd6
Reviewed-on: https://go-review.googlesource.com/c/term/+/443415
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2022-10-17 18:49:19 +00:00
cui fliter
7a66f970e0 term_test.go: replace io/ioutil with io and os package
For golang/go#45557

Change-Id: I27cfebf64dd4597e3f00ea3fbb32d670619b5c45
GitHub-Last-Rev: 4c4433c530
GitHub-Pull-Request: golang/term#9
Reviewed-on: https://go-review.googlesource.com/c/term/+/430798
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
v0.1.0
2022-09-19 17:04:32 +00:00
Russ Cox
a9ba230a40 A+C: delete AUTHORS and CONTRIBUTORS
In 2009, Google's open-source lawyers asked us to create the AUTHORS
file to define "The Go Authors", and the CONTRIBUTORS file was in
keeping with open source best practices of the time.

Re-reviewing our repos now in 2022, the open-source lawyers are
comfortable with source control history taking the place of the
AUTHORS file, and most open source projects no longer maintain
CONTRIBUTORS files.

To ease maintenance, remove AUTHORS and CONTRIBUTORS from all repos.

For golang/go#53961.

Change-Id: I049817224d2238c682ba92fbfba1d265bea183c8
Reviewed-on: https://go-review.googlesource.com/c/term/+/419104
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-07-22 15:52:59 +00:00
ardnew
065cf7ba24 x/term: prevent invalid indexing into stRingBuffer
The exported method (*stRingBuffer).NthPreviousEntry does not correctly
handle arguments with negative values. A negative value will index
beyond slice boundaries in most cases (unless size = max = INT_MAX) and
cause an access violation at runtime.

This change adds a condition to return ok = false for all negatively
valued arguments, which is the same behavior that occurs with positively
valued arguments exceeding buffer length.

Adding the capability to index backwards (from the end of the slice)
does not seem like the intent of this method, and it would not improve
or simplify existing functionality. It would also be inconsistent with
the handling of positive values out-of-bounds.

Change-Id: Ib4113330f0044dd5b73c7d75c5cdcdd27d60ee77
GitHub-Last-Rev: fec355f536
GitHub-Pull-Request: golang/term#8
Reviewed-on: https://go-review.googlesource.com/c/term/+/408754
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-26 00:47:31 +00:00
Russ Cox
e5f449aeb1 all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: Ib37025f3feda6c1ac63a48247a644dd5afac2be8
Reviewed-on: https://go-review.googlesource.com/c/term/+/399619
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-11 21:56:00 +00:00
Tobias Klauser
03fcf44c22 term: add codereview.cfg
This will let git codereview rewrite issue references to the golang/go
repo. See https://golang.org/cl/4131 for details.

Change-Id: I5d5871b8570cdd448949a5a984027f909ab521a5
Reviewed-on: https://go-review.googlesource.com/c/term/+/352590
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-27 22:27:41 +00:00
Tobias Klauser
f766a8b9ae term: enable TestMakeRawState on darwin/arm64
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Now that Go 1.16 is the oldest supported release, the ios tag can be
used exclusively to detect iOS and TestMakeRawState which ought to run
on darwin/arm64 can be enabled on that platform.

For golang/go#45696

Change-Id: Ic51903ea94def1f1144ca74db37533b5c4de8522
Reviewed-on: https://go-review.googlesource.com/c/term/+/352589
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-09-27 21:18:40 +00:00
Alan Donovan
140adaaadf term: add portability note re: std{in,out} fds
I recently made the mistake of assuming that stdin and stdout's
fds were 0 and 1, respectively, leading to a bug report from a
Windows user. With luck this note should prevent others from
making the same mistake.

Change-Id: I5391d91c431c3a801617f50d1b6a61121e2a939f
Reviewed-on: https://go-review.googlesource.com/c/term/+/349149
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
2021-09-16 21:49:54 +00:00
Bryan C. Mills
6886f2dfbf all: upgrade x/sys to latest
This fixes a build error observed in
https://build.golang.org/log/13b332a441d4d18d5358f87f945cafba3d7b9d4e.

Change-Id: I7ea6ba6e6bbeb30dabc28952306b28997410d07a
Reviewed-on: https://go-review.googlesource.com/c/term/+/328150
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-15 17:13:37 +00:00
Bryan C. Mills
a79de5458b go.mod: upgrade to go 1.17
This change was produced using 'go mod tidy -go=1.17'
with a go command built at CL 315210.

This activates lazy loading, and updates the go.mod file to maintain
the lazy-loading invariants (namely, including an explicit requirement
for every package transitively imported by the main module).

Note that this does *not* prevent users with earlier go versions from
successfully building packages from this module.

For golang/go#36460.

Change-Id: Iad25619ccbce82b91bbf51d13a79404c6e998dcc
Reviewed-on: https://go-review.googlesource.com/c/term/+/316112
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-03 06:03:54 +00:00
Tobias Klauser
c04ba851c2 term: unify ioctl{Read,Write}Termios definition for aix, linux, solaris & zos
These all use TCGETS/TCSETS. Rather than having a term_unix_$GOOS.go
file for each platform, unify them in a single file.

Change-Id: Iefeeadf9cf53d8fa32b1b15b8169744a819565c8
Reviewed-on: https://go-review.googlesource.com/c/term/+/314231
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-29 15:45:55 +00:00
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