| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| |
| |
| |
| |
| |
| | |
This makes use of the new TIOCGPTPEER pty ioctl() for directly opening a
PTY peer, without going via path names. This is nice because it closes a
race around allocating and opening the peer. And also has the nice
benefit that if we acquired an fd originating from some other
namespace/container, we can directly derive the peer fd from it, without
having to reenter the namespace again.
|
| |
| |
| |
| |
| | |
This opens a pty peer in one go, and uses the new race-free TIOCGPTPEER
ioctl() to do so – if it is available.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Various fixes:
1. Adds O_CLOEXEC for two socketpair()s where we forgot it.
2. Uses FORK_WAIT instead of manual wait_for_terminate_and_check()
invocations.
3. Prefix opaque NULL/0 arguments with comments what they are.
4. Add a banch of assert()s, and change flag validation in
open_terminal() to be assert() (since flags mistakes are programming
errors, not runtime errors).
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
OSC sequences can be closed with one of three terminators:
1. ASCII code 7, aka BEL, aka ^G, aka \x07, aka \a
2. ASCII code 156, aka \x9c
2. Pair of ASCII code 27 followed by ASCII code 92, aka \x1b\x5c
Of these, in some corner case scenarios BEL makes problem (see #34604).
Hence switch away from that wherever we use it, and prefer the \x1b\x5c
instead. That's preferable over \x9c, since the latter is also a valid
UTF-8 codepoint. See discussion here for example:
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence
Fixes: #34604
|
|
|
|
|
|
|
|
|
|
| |
to a TTY
Let's provide a mechanism to select the number of screen columns for
rebreaking comments in Varlink IDL connected to a TTY, by honouring the
$COLUMNS env var then too. Previously we'd only honour when connected to
a TTY, but it's also useful otherwise for rebreaking ridiculously long
comments, hence honour it in this case too.
|
| |
|
|
|
|
|
|
|
| |
This mirrors the behavior of `systemd-firstboot` and allows bootup
messages to settle down before user input is actually processed.
See: https://github.com/systemd/systemd/issues/34448
|
|
|
|
| |
Follow-up for 14f594b995bbaea85456a4c26e5c07446a4c446e
|
| |
|
|
|
|
|
|
|
|
|
| |
let's instead generate ENOTTY on our own. This is more correct with out
coding style (since we generally do not propagate errors via errno), and
also addresses #34039 as side effect. (#34039 really needs to be fixed
in musl though, too, this is just a work-around as side-effect).
Fixes: #34039
|
|
|
|
|
|
|
|
|
|
| |
glibc returs EIO on ttys that are hung up. That's not really correct,
POSIX seems to disagree.
Work around this in our code, and turn this into a clean "1", since a
hung up tty doesn't stop being a tty just because it is hung up.
Background: https://github.com/systemd/systemd/pull/34039
|
|
|
|
| |
This is pointless and noisy even for debug level.
|
|
|
|
|
|
|
|
|
| |
When pid 1 crashes, the getty unit for the console will happily keep
running which means we end up with two shells competing for the same
tty. Let's call vhangup on /dev/console to kill every other process
attached to the console before we spawn the crash shell. The getty
units have Restart=always but lucky for us, pid 1 just crashed in fire
and flames so it isn't actually able to restart the getty unit.
|
|
|
|
|
|
|
|
| |
initialized
Various tty types come up with cols/rows not initialized (i.e. set to
zero). Let's detect these cases, and return a better error than EIO,
simply to make things easier to debug.
|
|
|
|
|
| |
I managed to hit the timeout a couple of times inside of slow qemu.
Let's increase it a bit to 1/3s
|
|
|
|
| |
get_default_background_color()
|
| |
|
|
|
|
|
|
|
|
| |
/dev/console being a symlink
/dev/console is sometimes a symlink in container managers. Let's handle
that correctly, and resolve the symlink, and not consider the data from
/sys/ in that case.
|
|
|
|
|
|
|
|
| |
It doesn't really make sense to have that in dev-setup.c, which is
mostly about setting up /dev/, creating device nodes and stuff.
let's move it to the other stuff that deals with /dev/console's
peculiarities.
|
|
|
|
|
|
|
|
|
|
| |
Numerous fixes:
1. use vtnr_from_tty() to parse out VT number from tty path
2. open tty for write only when we want to output just ansi sequences
3. open tty in asynchronous mode, and apply a timeout, just to be safe
4. propagate error from writing (most callers ignore it anyway, might as
well pass it along correctly)
|
| |
|
|
|
|
|
|
|
|
|
| |
This is a lot of stuff, and sometimes quite wild, let's turn this into
its own header.
All stuff color-related that just generates sequences is now in
ansi-color.h (no .c file!), and everything more complex that
probes/ineracts with terminals remains in termina-util.[ch]
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Let's update the commentary a bit. Also, use a time-out of 100ms rather
than 50ms for this, simply to unify on the same value used in
vt_disallocate() in a similar case.
|
|
|
|
|
|
|
| |
anymore
We only use them in terminal-util.c, hence make them static (and move
them before their first using function).
|
|
|
|
|
|
| |
Let's put "terminal_" as prefix, like with the other reset calls, and
let's make clear that this only encapsulates the ioctl-based reset
logic, not the ANSI sequence based reset logic.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
the screen
ESC c is a (vaguely defined) "reset to initial state" ANSI sequence.
Many terminals clear the screen in this case, but that's a bit drastic I
think for most resets.
ESC c was added to the reset logic in
00bc83a275fa3ca8d90579fe9597d8b651d47332 (i.e. very recently), and I
don't think the effect was clear at that time.
Let's keep the ESC c in place however when we actually want to clear the
screen. Hence move it from reset_terminal_fd() into vt_disallocate().
Fixes: #33689
|
|
|
|
| |
reset-by-ioctl and reset-by-sequence reasonably
|
|
|
|
| |
The helper checks if an fd references a pty
|
|
|
|
| |
We have pretty much the same code at two places, let's make it one.
|
|
|
|
|
|
| |
This appears to have been the intention of
00bc83a275fa3ca8d90579fe9597d8b651d47332, judging by the comments on
that.
|
|
|
|
|
|
| |
make_console_stdio()
Let's hook this up.
|
|
|
|
| |
acquired via ANSI sequences
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we are talking to a serial terminal quite commonly the dimensions
are not set properly, because the serial protocol has not handshake or
similar to transfer this information.
However, we can derive the dimensions via ANSI sequences too, which
should get us the right information, since ANSI sequences are
interpreted by the final terminal, rather than an intermediary local tty
driver (which is where TIOCGWINSZ is interpreted).
This adds a helper call that gets the dimensions this way.
|
|
|
|
|
|
|
|
| |
terminal_set_cursor_position()
Let's prefix these functions with the subsystem name, and clean them up
a bit. Specifically, drop the error logging, it's entirely duplicative,
since every single caller does it anyway.
|
|
|
|
|
|
|
|
|
|
|
| |
to same tty
Let's add an extra safety check: before issuing the ansi sequence to
query the bg color, let's make sure input and output fd actually
reference the same tty. because otherwise it's unlikely we'll be able to
read back the response from the tty driver.
This is mostly just paranoia.
|
| |
|
|
|
|
|
| |
This doesn't make much of a different IRL, but it feels more right that
an operation that happens in input is turned off via the input fd.
|
|
|
|
|
|
| |
If we only read partial information from the tty we ended up parsing it
again and again, confusing the state machine. hence, return how much
data we actually processed and drop it from the buffer.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
We use this at various places, let's unify this in one global constant.
This changes flags in crash-handler.c in a tiny irrelevant way: we ask
syscalls to be continued on signal arrival, which we previously didn't.
But that shouldn't change anything, the only thing we'll do in the
relevant process is call raise(), and that's it, hence there definitely
are no syscalls to restart or not to restart.
|
|
|
|
|
|
|
| |
- introduce or rename usual enum values _MAX and _INVALID,
- introduce and use string table lookup functions,
- split out implementation of get_color_mode() to _impl(),
- add tests for get_color_mode().
|
|
|
|
|
|
|
| |
Currently, we assume that there is no restriction on coloring when
COLOR_24BIT. Let's merge the two values.
Follow-up for a5efbf468c96190c9562bc8121eda32310dfd112.
|