-
Notifications
You must be signed in to change notification settings - Fork 22
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
Make the mechanism for escaping tunable and discoverable & send raw ^C's directly #297
base: master
Are you sure you want to change the base?
Conversation
I think it would be good to use an escape sequence like For I'd also add an |
In general I agree that control characters should be ignored locally in favor of an escape character.
Perhaps consider one of the lesser-used control characters? Ones I've seen used include ^E, ^, and ^^. |
One concern I have is that mixing messages from the tool with output on the console might be confusing. Perhaps the instructions on how to escape the console could be in the CLI command help message? (I think this is unlikely to come up for the web console version, but if it did that could perhaps be help text somewhere on the page outside of the console itself.) |
I second this. Many moons ago, I'd drafted a change to propolis-cli to implement this (
It works fine in
Agreed. |
Yeah mixing console output is definitely confusing. In sercons we print a message prior to attaching about what sequence to press to detach, and then don't otherwise intermingle output. SSH only emits stuff when you use something explicit like the help screen. sercons is https://github.com/jclulow/vmware-sercons FWIW and I use it to attach to the serial console in propolis standalone which is just a UNIX socket. It's been pretty good. |
Wouldn't a way around that be to use an uncommon control character by itself? There's precedent for this; e.g.
That's literally what you're going to type when adding a multiline comment at the top of, say, /etc/hosts, isn't it?
etc.
There's precedent here we can look at; for example telnet. |
A single byte escape sequence is not great, because there is no way to escape the original byte when you need to generate it -- especially when the escape sequence is just terminating the session, not opening a prompt like
I don't believe so. Note that it is a three byte sequence: In some software like If you do want to start a comment line with
There's also precedent in |
Dunno. It worked fine for 15 or so years until people stopped regularly using telnet. Even now, it's not so onerous when one does use telnet for something (that's not usually the telnet protocol). Even then, it wasn't the control character that was the problem. But let me be clear here: I'm not saying you shouldn't precede the escape character by a or whatever, but I am suggesting it's a bit surprising that it's a fairly common printing character.
This is moving the goal posts a tad. The original suggestion was, "to use an escape sequence like ssh (and tip and sercons and zlogin -C do for breaking the connection (and potentially taking other actions)." It's true that sercons seems to only support that single escape sequence, but
Wouldn't that start the line with
I was referring specifically to differentiating between tool output and console output here. |
well these all sound like improvements of some sort over the current state of affairs -- i can certainly say the existing scheme of the and evidently the choice of escape sequence in this paradigm (as ourselves choosing a default or as the user passing one to making it a cli switch also neatly solves the problem of making it discoverable, which means we certainly don't have to worry about asking if the user wanted to SIGINT us or send it across on stderr like this; they can hopefully think to (edit: fwiw, the change i pushed just now can be made to behave like ssh if you pass |
ba3d76a
to
0f16274
Compare
well, i just now threw a regex at the problem and somehow didn't end up with two problems. :) |
93a3aa4
to
1f3ee82
Compare
Thanks for doing this @lifning, this will allow Falcon drop some copied code and use the propolis client serial implementation directly (issue linked above). Something that would be really nice as a follow on, would be to expose this functionality through a library for direct consumption in other programs rather than having to shell out. |
30b5bb5
to
ec2a487
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to review this in more detail, but I have some high level questions/feedback that I think I want to hash out first.
I like the spirit of being able to specify custom escape sequences, but I have a few concerns with the approach. Specifically:
- I'm worried that that prefix length being in bytes and the escape sequence allowing multibyte characters (I think) means that you could construct a string that ends in the middle of a character and send that to the guest. That seems like it could have some security implications or just generally cause surprising behavior.
- On that note, I think I would want to be a bit more up front about what characters are allowed in the escape sequence. Is it UTF-8? Should we restrict the available set of characters somehow?
- This might be my own ignorance here, but I'm not sure why a regex is needed to check for the escape string when the previous implementation didn't use one (and was much clearer to me what was going on).
- I think the logic that checks for the escape sequence could benefit from some "helper" functions that pull out the checks into named functions to help explain what's going on. And a block comment of some kind to explain why we are doing this would help.
I left a couple other comments from when I had started reviewing, but they're minor and I wanted to raise these things first.
ec2a487
to
b6e8f63
Compare
the escape sequence does allow multibyte characters -- which clap does happen to require to be valid UTF-8, despite being carried in an i hesitated to restrict things here because i don't/can't know what manner of obscure byte sequence someone might hypothetically want to use someday, particularly operators using more interesting keyboards (various international ones, or soft keyboards on the smartphone an on-call operator getting paged while away from a PC might be remoting in from -- if they wanna make like a tree and
the use of a regex here is specifically to work around the issue Patrick described encountering in a comment above, which turned out to be: when you send a newline to most shells, they'll output an ANSI escape sequence for cursor position request, to which
will do! Footnotes
|
bdc0d97
to
4ee7324
Compare
4ee7324
to
69f2578
Compare
69f2578
to
5802f52
Compare
This changes the method of entering an escape sequence: - raw Ctrl+C gets sent to the VM unimpeded. - by default, the sequence Ctrl+], Ctrl+C is used to quit the program (`^]^C`) - this can be customized or removed via CLI flags, allowing the string be of arbitrary length. - i.e. if you `propolis-cli serial -e "beans"` and then type "bea", nothing gets sent to the VM after the "b" yet. and then if you type: 1. "k", the VM gets sent "beak" 2. '"ns", the VM doesn't get sent anything else, and the client exits. - the client can be configured to pass through an arbitrary prefix length of the escape string before it starts suppressing inputs, such that you can, for example, mimic ssh's Enter-tilde-dot sequence without temporarily suppressing Enter presses not intended to start an escape sequence, which would interfere with function: `-e '^M~.' --escape-prefix-length=1` (this also works around ANSI escape sequences being sent by xterm-like emulators when Enter is pressed in a shell that sends a request for such) Much of this logic, including RawTermiosGuard, has now been factored out into the https://github.com/oxidecomputer/thouart crate.
5802f52
to
2633a39
Compare
(edited, for context this used to just be a commit that added a warning message the first time you hit a raw Ctrl+C, now it changes the behavior of the escape handling altogether as described below)
This changes the method of entering an escape sequence:
^]^C
)propolis-cli serial -e "beans"
and then type "bea", nothing gets sent to the VM after the "b" yet. and then if you type:-e '^M~.' --escape-prefix-length=1
(this also includes a workaround for ANSI escape sequences being sent by xterm-like emulators when Enter is pressed in a shell that sends a request for such)
Hopefully no more accidentally killing the client!