1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00
Commit Graph

75114 Commits

Author SHA1 Message Date
Lennart Poettering
27c067ceeb execute: reorder "destructive" tty reset operations
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).
2024-07-19 11:44:04 +02:00
Lennart Poettering
85f3957072 exec-invoke: handle errno log message writing in write_confirm_error_fd() like we usually do 2024-07-19 11:44:04 +02:00
Lennart Poettering
83e5672f90 exec-invoke: save original stdin/stdout with O_CLOEXEC set
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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
3f2e8e951a execute: also hook up ansi-seq-based terminal size determination with 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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
967bcc6e26 tree-wide: reset stdout not stdin
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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
45d785dfc0 terminal-util: refactor vt_disallocate()
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)
2024-07-19 11:44:04 +02:00
Lennart Poettering
7147e10c9e terminal-util: move acquire_terminal() and AcquireTerminalFlags back together in header file 2024-07-19 11:44:04 +02:00
Lennart Poettering
061b445828 terminal-util: simplify terminal_set_size_fd() a tiny bit 2024-07-19 11:44:04 +02:00
Lennart Poettering
b7120388f8 terminal-util: split out color macros/helpers into its own header
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]
2024-07-19 11:44:04 +02:00
Lennart Poettering
1ca3924827 terminal-util: remove terminal_vhangup() because apparently unused 2024-07-19 11:44:04 +02:00
Lennart Poettering
ac508b1173 terminal-util: rename return parameters ret_xyz 2024-07-19 11:44:04 +02:00
Lennart Poettering
af1d3a6d92 terminal-util: modernize vt_reset_keyboard() a bit 2024-07-19 11:44:04 +02:00
Lennart Poettering
b61c015aeb terminal-util: don't export vt_reset_keyboard() + vt_default_utf8() 2024-07-19 11:41:43 +02:00
Lennart Poettering
524e1240ff terminal-util: modernize terminal_reset_ansi_seq() a bit
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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
e2216800c5 terminal-util: don't export terminal_reset_ioctl()/terminal_reset_ansi_seq() anymore
We only use them in terminal-util.c, hence make them static (and move
them before their first using function).
2024-07-19 11:41:43 +02:00
Lennart Poettering
5a4e541779 terminal-util: rename reset_terminal_fd() → terminal_reset_ioctl()
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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
12f1b0134a terminal-util: remove reset_terminal() as it is unused 2024-07-19 11:41:43 +02:00
Lennart Poettering
841eb9c186 terminal-util: don't issue "ESC c" sequence on reset, but only when erasing 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
00bc83a275 (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
2024-07-19 11:41:43 +02:00
Lennart Poettering
cfac09083b terminal-util: add new helper terminal_reset_defensive() that combines reset-by-ioctl and reset-by-sequence reasonably 2024-07-19 11:41:43 +02:00
Lennart Poettering
ce3a1593bc terminal-util: add terminal_is_pty_fd() helper
The helper checks if an fd references a pty
2024-07-19 11:41:43 +02:00
Lennart Poettering
2736295ddb terminal-util: unify code that resets /dev/console in common helper
We have pretty much the same code at two places, let's make it one.
2024-07-19 11:41:43 +02:00
Lennart Poettering
963e25c23b terminal-util: reset /dev/console via ansi seq also in make_console_stdio()
This appears to have been the intention of
00bc83a275, judging by the comments on
that.
2024-07-19 11:41:43 +02:00
Lennart Poettering
f6927e3c98 terminal-util: try to initialize rows/cols via ansi sequence in make_console_stdio()
Let's hook this up.
2024-07-19 11:41:43 +02:00
Lennart Poettering
63c631d7e2 terminal-util: add helper that adjust terminal width/height from data acquired via ANSI sequences 2024-07-19 11:41:43 +02:00
Lennart Poettering
3390be38d1 terminal-util: add helper that queries terminal sizes via ANSI sequence
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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
53f0ab5151 terminal-util: rename set_terminal_cursor_position() → 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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
445e57387e terminal-util: when querying bg color, ensure input fd and output fd refer 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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
0e08325baa terminal-util: remember error code from tcsetattr() 2024-07-19 11:41:43 +02:00
Lennart Poettering
1c685216f4 terminal-util: turn off echo on stdin, not stdout
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.
2024-07-19 11:41:43 +02:00
Lennart Poettering
1df569b2e6 terminal-util: don't process the same data twice when reading back bg color info
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.
2024-07-19 11:41:42 +02:00
Lennart Poettering
4c8c499e2c terminal-util: return correct error in chvt() 2024-07-19 11:41:42 +02:00
Lennart Poettering
9a5e421af5 terminal-util: refuse a few more unexpected open flags in open_terminal() 2024-07-19 11:41:42 +02:00
Lennart Poettering
845be16ffd terminal-util: trivial white space fix 2024-07-19 11:41:42 +02:00
Lennart Poettering
cc915eefaf env-util: suppress unnecessary setenv() in setenvf() 2024-07-19 11:41:42 +02:00
Lennart Poettering
95a8308d53 vmspawn: make "-n" just work
The tap network device should be called "vt-", so that that the
80-vm-vt.network file we ship by default actually matches against it.

Also, turn off any qemu callout stuff, networkd is smart enough to
handle all this on its own, without ugly callouts.
2024-07-19 11:38:46 +02:00
Luca Boccassi
68d939350f
Merge pull request #33591 from teknoraver/o_path
use O_PATH when possible
2024-07-19 11:01:01 +02:00
Luca Boccassi
433b9a6884
Merge pull request #33770 from bluca/polkit-root
polkit: map POLKIT_ALWAYS_QUERY to new polkit flag
2024-07-19 10:57:07 +02:00
Lucas Werkmeister
8c4aa0f1c6 man: Mention Type=oneshot timeout directive
Make the warning for oneshot services (where RuntimeMaxSec= has no
effect) more actionable by pointing to the directive people can use
instead to effectively limit their runtime.
2024-07-19 09:39:51 +02:00
Luca Boccassi
20de757b69
Merge pull request #33773 from kovalev0/fix_aquarius_cmp_ns483_keyb_and_sensor
Fix aquarius cmp ns483 keyboard and sensor
2024-07-18 22:28:23 +02:00
Vasiliy Kovalev
3585e55881 hwdb: add backslash and touchpad toggle mapping for Aquarius Cmp NS483
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
2024-07-18 22:07:36 +03:00
Vasiliy Kovalev
8891f9332f hwdb: fix accelerometer mount matrix for Aquarius Cmp NS483
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
2024-07-18 22:07:33 +03:00
Luca Boccassi
d108c2d157
Merge pull request #33767 from keszybz/test-ukify-nicer
Make test_ukify not use a real initrd
2024-07-18 17:59:55 +02:00
Luca Boccassi
b61d69fae0 polkit: fix typo in enum name 2024-07-18 16:43:56 +01:00
Léane GRASSER
0d8b38415c l10n: fix credits for the French translation 2024-07-18 17:14:48 +02:00
Luca Boccassi
5c48335ef4 polkit: map POLKIT_ALWAYS_QUERY to new polkit flag
polkitd by default just waves through requests from a root process.
A new POLKIT_CHECK_AUTHORIZATION_FLAGS_ALWAYS_CHECK flag was added
to main (will be part of v125 when it ships) that forces it to go
through the policy checks for root too. Previous versions will just
ignore it.

Change the flags handling slightly so that we pass this or the
interactive flags through, as the values match what polkit expects.
2024-07-18 16:11:26 +01:00
Daan De Meyer
4698411ff3
Merge pull request #33763 from DaanDeMeyer/mkosi
mkosi: Two fixlets
2024-07-18 16:43:15 +02:00
Lennart Poettering
46b89b83e3 ptyfwd: reset color after two tty reset sequences, too
When we patch in a bg color we must make sure that when certain "reset"
sequences are transferred we fix up the bg color again.

Do so for \033[!p ("soft terminal reset") and \033c ("reset to initial
state" aka "full reset").
2024-07-18 15:41:33 +02:00
Zbigniew Jędrzejewski-Szmek
a669091a43 test_ukify: add instructions
Copied directly from a1d6dbb1c9.
2024-07-18 15:04:28 +02:00
Zbigniew Jędrzejewski-Szmek
87204601df test_ukify: use sha384 in the signing tests
On Fedora, with crypto policy TEST-FEDORA41, sha1 is not allowed:

$ SYSTEMD_LOG_LEVEL=debug build/systemd-measure sign
  --linux=/lib/modules/6.9.7-200.fc40.x86_64/vmlinuz
  --osrel=/tmp/tmp.osrelbl2sr77f
  --cmdline=/tmp/tmp.cmdlineouc7hqtj
  --uname=/tmp/tmp.unamecbjgesty
  --pcrpkey=/tmp/tmpufiadu8l
  --initrd=/boot/3a9d668b4db749398a4a5e78a03bffa5/6.9.7-200.fc40.x86_64/initrd
  --sbat=/tmp/tmp.sbataz9arpy0
  --private-key=/tmp/tmppyf0gx6w
  --public-key=/tmp/tmpufiadu8l
  --bank=sha1
Measuring boot phases: enter-initrd, enter-initrd:leave-initrd, enter-initrd:leave-initrd:sysinit, enter-initrd:leave-initrd:sysinit:ready
Loaded 'libtss2-esys.so.0' via dlopen()
Loaded 'libtss2-rc.so.0' via dlopen()
Loaded 'libtss2-mu.so.0' via dlopen()
PolicyPCR calculated digest: cec1a2ccb188ddd171a2be7bfa6b31cb9148776647354eb1069e0f891ed2dbe7
Failed to initialize signature context: error:03000098:digital envelope routines::invalid digest
Failed to sign PCR policy: Input/output error
2024-07-18 15:04:28 +02:00
Zbigniew Jędrzejewski-Szmek
987f4bce93 test_ukify: do not use files from /boot
They might not be readable to the unprivileged user running the tests
and it shouldn't really matter what is used. OTOH, we need a real kernel
because we look at the header.
2024-07-18 15:04:28 +02:00