summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* docs: Document how to do stable releasesDaan De Meyer2024-07-191-0/+6
|
* Merge pull request #33707 from poettering/terminal-size-by-ansi-seqLennart Poettering2024-07-1958-544/+1125
|\ | | | | pid1: try to initialize terminal dimensions from data gathered via ANSI sequences + many clean-ups/refactorings
| * pid1: use $COLUMNS info in status_vprintf()Lennart Poettering2024-07-191-2/+8
| | | | | | | | | | This way, we can work around the fact that "struct winsize" for /dev/console might not be initialized the moment we open the device.
| * main: set $COLUMNS/$ROWS for PID 1 based on /dev/console dataLennart Poettering2024-07-191-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In PID 1 we write status information to /dev/console regularly, but we cannot keep it open continously, due to the kernel's SAK logic (which would kill PID 1 if user hits SAK). But closing/reopening it all the time really sucks for tty types that have no window size management (such as serial terminals/hvc0 and suchlike), because it also means the TTY is fully closed most of the time, and that resets the window sizes to 0/0. Now, we reinitialize the window size on every reopen, but that is a bit expensive for simple status output. Hence, cache the window size in the usualy $COLUMNS/$ROWS environment variables. We don't inherit these to our payloads anyway, hence these are free to us to use.
| * terminal-util: add recognizable error if cols/rows of tty are initially not ↵Lennart Poettering2024-07-191-2/+2
| | | | | | | | | | | | | | | | 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.
| * terminal-util: extend timeout on background color requestLennart Poettering2024-07-191-1/+1
| | | | | | | | | | I managed to hit the timeout a couple of times inside of slow qemu. Let's increase it a bit to 1/3s
| * terminal-util: try to avoid reading more from terminal than we need in ↵Lennart Poettering2024-07-191-3/+6
| | | | | | | | get_default_background_color()
| * exec-invoke: user EBADF where appropriateLennart Poettering2024-07-191-1/+1
| |
| * tree-wide: acquire /dev/console lock around any attempts to reset TTYLennart Poettering2024-07-196-3/+22
| |
| * terminal-util: teach resolve_dev_console() to deal correctly with ↵Lennart Poettering2024-07-191-6/+20
| | | | | | | | | | | | | | | | /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.
| * terminal-util: move lock_dev_console() hereLennart Poettering2024-07-196-21/+18
| | | | | | | | | | | | | | | | 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.
| * man: clarify what TTYReset= and TTYVTDisallocate= do and do not do regarding ↵Lennart Poettering2024-07-191-6/+9
| | | | | | | | screen clearing
| * units: bring agetty command lines back into syncLennart Poettering2024-07-194-9/+10
| | | | | | | | | | | | | | | | | | | | Let's always rely on our own TTY reset logic and tty disallocation/clear screen logic, thus always pass --noclear and --noreset. Also, bring the list of baud rates to try into sync for console-getty and serial-getty (the former might or might not be connected to rs232, we can't know, hence assume the worst, and copy what serial-getty@.service does)
| * exec-invoke: move terminal initialization a bitLennart Poettering2024-07-192-13/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's a bit confusing, but we actually initialize the terminal twice for each service, potentially. One earlier time, where we might end up firing vhangup() and vt_disallocate(), which is a pretty brutal way to reset things, by disconnecting and possibly invalidating the tty completely. When we do this we do not keep any fd open afterwards, since it quite likely points to a dead connection of a tty. The 2nd time we initialize things when we actually want to use it. The first initialization is hence "destructive" (killing any left-overs from previous uses) the 2nd one "constructive" (preparing things for our new use), if you so will. Let's document this distinction in comments, and let's also move both initializations to exec_invoke(), so that they are easier to see in their symmetric behaviour. Moreover, let's run the tty initialization after we opened both input and output, since we need both for doing the fancy dimension auto init stuff now. Oh, and of course, one thing to mention: we nowadays initialize terminals both with ioctl() and with ansi sequences. But the latter means we need an fd that is open for *write* (since we are *writing* those ansi sequences to the tty). Hence, resetting via the input fd is conceptually wrong, it worked only so far if we had O_RDWR open mode selected)
| * execute: reorder "destructive" tty reset operationsLennart Poettering2024-07-191-5/+11
| | | | | | | | | | | | Let's make sure to first issue the non-destructive operations, then issue the hangup (for which we need the fd), then try to disallocate the device (for which we don't need it anymore).
| * exec-invoke: handle errno log message writing in write_confirm_error_fd() ↵Lennart Poettering2024-07-191-6/+7
| | | | | | | | like we usually do
| * exec-invoke: save original stdin/stdout with O_CLOEXEC setLennart Poettering2024-07-191-2/+2
| | | | | | | | | | | | We turn off the flag anyway when we install them back as stdin/stdout later (via dup2()). let's hence follow our usual rules, and turn on O_CLOEXEC.
| * execute: also hook up ansi-seq-based terminal size determination with ↵Lennart Poettering2024-07-193-25/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | exec_context_determine_size() And while we are at it, merge exec_context_determine_tty_size() + exec_context_apply_tty_size(). Let's simplify things, and merge the two funcs, since the latter just does one more call. At the same time, let's make sure we actually allow passing separate input/output fds.
| * tree-wide: reset stdout not stdinLennart Poettering2024-07-194-5/+5
| | | | | | | | | | | | | | We nowadays reset TTYs by writing ANSI sequences to them. This can only work if we operate on an *output* fd, not an input fd. Hence switch various cases where we erroneously used an input fd to use an output fd instead.
| * terminal-util: refactor vt_disallocate()Lennart Poettering2024-07-191-40/+19
| | | | | | | | | | | | | | | | | | | | 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)
| * terminal-util: move acquire_terminal() and AcquireTerminalFlags back ↵Lennart Poettering2024-07-191-3/+3
| | | | | | | | together in header file
| * terminal-util: simplify terminal_set_size_fd() a tiny bitLennart Poettering2024-07-191-2/+7
| |
| * terminal-util: split out color macros/helpers into its own headerLennart Poettering2024-07-1941-158/+201
| | | | | | | | | | | | | | | | | | 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]
| * terminal-util: remove terminal_vhangup() because apparently unusedLennart Poettering2024-07-192-11/+0
| |
| * terminal-util: rename return parameters ret_xyzLennart Poettering2024-07-192-9/+9
| |
| * terminal-util: modernize vt_reset_keyboard() a bitLennart Poettering2024-07-191-3/+8
| |
| * terminal-util: don't export vt_reset_keyboard() + vt_default_utf8()Lennart Poettering2024-07-192-24/+22
| |
| * terminal-util: modernize terminal_reset_ansi_seq() a bitLennart Poettering2024-07-191-2/+2
| | | | | | | | | | | | 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.
| * terminal-util: don't export terminal_reset_ioctl()/terminal_reset_ansi_seq() ↵Lennart Poettering2024-07-192-104/+101
| | | | | | | | | | | | | | anymore We only use them in terminal-util.c, hence make them static (and move them before their first using function).
| * terminal-util: rename reset_terminal_fd() → terminal_reset_ioctl()Lennart Poettering2024-07-192-4/+4
| | | | | | | | | | | | 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.
| * terminal-util: remove reset_terminal() as it is unusedLennart Poettering2024-07-192-15/+0
| |
| * terminal-util: don't issue "ESC c" sequence on reset, but only when erasing ↵Lennart Poettering2024-07-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * terminal-util: add new helper terminal_reset_defensive() that combines ↵Lennart Poettering2024-07-198-8/+36
| | | | | | | | reset-by-ioctl and reset-by-sequence reasonably
| * terminal-util: add terminal_is_pty_fd() helperLennart Poettering2024-07-193-0/+71
| | | | | | | | The helper checks if an fd references a pty
| * terminal-util: unify code that resets /dev/console in common helperLennart Poettering2024-07-193-42/+35
| | | | | | | | We have pretty much the same code at two places, let's make it one.
| * terminal-util: reset /dev/console via ansi seq also in make_console_stdio()Lennart Poettering2024-07-191-0/+4
| | | | | | | | | | | | This appears to have been the intention of 00bc83a275fa3ca8d90579fe9597d8b651d47332, judging by the comments on that.
| * terminal-util: try to initialize rows/cols via ansi sequence in ↵Lennart Poettering2024-07-191-4/+5
| | | | | | | | | | | | make_console_stdio() Let's hook this up.
| * terminal-util: add helper that adjust terminal width/height from data ↵Lennart Poettering2024-07-193-0/+47
| | | | | | | | acquired via ANSI sequences
| * terminal-util: add helper that queries terminal sizes via ANSI sequenceLennart Poettering2024-07-193-0/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-util: rename set_terminal_cursor_position() → ↵Lennart Poettering2024-07-194-18/+13
| | | | | | | | | | | | | | | | 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.
| * terminal-util: when querying bg color, ensure input fd and output fd refer ↵Lennart Poettering2024-07-191-2/+34
| | | | | | | | | | | | | | | | | | | | | | 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.
| * terminal-util: remember error code from tcsetattr()Lennart Poettering2024-07-191-1/+1
| |
| * terminal-util: turn off echo on stdin, not stdoutLennart Poettering2024-07-191-2/+2
| | | | | | | | | | 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.
| * terminal-util: don't process the same data twice when reading back bg color infoLennart Poettering2024-07-191-24/+43
| | | | | | | | | | | | 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.
| * terminal-util: return correct error in chvt()Lennart Poettering2024-07-191-1/+1
| |
| * terminal-util: refuse a few more unexpected open flags in open_terminal()Lennart Poettering2024-07-191-1/+1
| |
| * terminal-util: trivial white space fixLennart Poettering2024-07-191-1/+1
| |
| * env-util: suppress unnecessary setenv() in setenvf()Lennart Poettering2024-07-191-0/+5
| |
* | mkosi: Bump default device timeout a littleDaan De Meyer2024-07-191-1/+1
| | | | | | | | | | | | We've been getting some integration test failures due to timeouts on finding the root partition device. Let's bump the default device timeout a little to see if it mitigates these failures.
* | hwdb: Add mic mute key mapping for Dell Pro Rugged seriesKai-Chuan Hsieh2024-07-191-0/+2
|/