Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore terminal state on interrupt or exit #13382

Merged
merged 3 commits into from
Jun 10, 2022

Conversation

codingllama
Copy link
Contributor

Fixes an issue with ContextReader on bash where abandoned password reads cause the terminal to remain "locked" even after tsh exits. This happens on interrupts but also on regular exit if the user picks a security key in the dual security key/OTP login prompt.

Doesn't seem to affect shells like zsh or fish.

Repro steps:

$ bash

# repro #1
$ ./tsh login --proxy=example.com
> Enter password for Teleport user llama: <CTRL-C>
# shell is now locked

# repro #2
# (Use an account with security key and OTP MFA.)
$ ./tsh login --proxy=example.com
> Enter password for Teleport user llama: <enters password>
> Tap any security key or enter a code from a OTP device <taps security key>
# shell is now locked

@codingllama codingllama requested a review from nklaassen June 10, 2022 15:38
@github-actions github-actions bot added the tsh tsh - Teleport's command line tool for logging into nodes running Teleport. label Jun 10, 2022
@codingllama
Copy link
Contributor Author

Thanks @nklaassen for the initial report.

Planning on backporting to branch/v10.

}

// iAmHoldingTheLock exists only to draw attention to the need to hold the lock.
type iAmHoldingTheLock struct{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't seen this one before. In most places we just suffix the method name with Locked to indicate that you should hold the lock before calling.

Not that there's anything wrong with this. It's just different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do the Locked suffix too, no strong preferences as long as something calls attention to it.

lib/utils/prompt/context_reader_test.go Outdated Show resolved Hide resolved
lib/utils/prompt/context_reader_test.go Show resolved Hide resolved
lib/utils/prompt/context_reader_test.go Show resolved Hide resolved
tool/tsh/tsh.go Outdated Show resolved Hide resolved
@codingllama codingllama force-pushed the codingllama/contextreader-interrupt branch from a9e2e3b to 4466534 Compare June 10, 2022 17:17
@codingllama
Copy link
Contributor Author

Addressed comments, PTAL?

@codingllama
Copy link
Contributor Author

Thanks everyone, I'll merge while it's green.

@codingllama codingllama merged commit 0ecf31d into master Jun 10, 2022
@codingllama codingllama deleted the codingllama/contextreader-interrupt branch June 10, 2022 17:44
codingllama added a commit that referenced this pull request Jun 23, 2022
codingllama added a commit that referenced this pull request Jun 24, 2022
codingllama added a commit that referenced this pull request Jun 24, 2022
`prompt.ContextReader`, along with various parts of `lib/utils/prompt`, where
re-written in master so we can alleviate input swallowing issues.

For various reasons I didn't backport all changes to v9, but the less-eager
input-swallowing loop is now what stands between us and issue #13021.

This isn't a backport of a specific PR, but instead a port of the entire
`lib/utils/prompt` package, as the PRs that touch the package unfortunately do
more than we want to backport. The interfaces are still compatible and I did
test various `tsh login` and `tsh ssh` scenarios.

I've thrown in #13382 for good measure, as well.

Closes #13021.

* Backport lib/utils/prompt improvements
* Fix lib/client tests
* Restore terminal state on exit (#13382)
@marcoandredinis marcoandredinis removed their request for review March 24, 2023 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants