1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-09 01:18:19 +03:00
Commit Graph

75098 Commits

Author SHA1 Message Date
Mike Yuan
60b218e36e test-execute: ExecStop= and friends should not get credentials
See #32583
2024-07-21 19:10:58 +01:00
Kamil Szczęk
88cf0906aa cryptsetup: handle parallel activation of volumes with another tool gracefully
This commit makes systemd-cryptsetup exit with a successful status when
the volume gets unlocked outside of the current systemd-cryptsetup
process while it was executing. This can be easily reproduced by calling
systemd-cryptsetup, and while it waits for user to input a password/PIN,
unlock the volume in a second terminal. Then after entering the password
systemd-cryptsetup will exit with a non-zero status code.
2024-07-21 19:02:59 +01:00
Luca Boccassi
eab98338f8
Merge pull request #33443 from YHNdnzj/oneshot-destroy-cred
core/service: destroy runtime data when Type=oneshot services exit
2024-07-21 18:44:25 +01:00
Etienne Champetier
0a4ecc54cb udev-builtin-net_id: use firmware_node/sun for ID_NET_NAME_SLOT
pci_get_hotplug_slot() has the following limitations:
- if slots are not hotpluggable, they are not in /sys/bus/pci/slots.
- the address at /sys/bus/pci/slots/X/addr doesn't contains the function part,
  so on some system, 2 different slots with different _SUN end up with the same
  hotplug_slot, leading to naming conflicts.
- it tries all parent devices until it finds a slot number, which is incorrect,
  and what led to NAMING_BRIDGE_MULTIFUNCTION_SLOT being disabled.

The use of PCI hotplug to find the slot (ACPI _SUN) was introduced in
0035597a30
"udev: net_id - export PCI hotplug slot names" on 2012/11/26.
At the same time on the kernel side we got
bb74ac23b1
"ACPI: create _SUN sysfs file" on 2012/11/16.

Using PCI hotplug was the only way at the time, but now 12 years later we can use
firmware_node/sun sysfs file.
Looking at a small selection of server HW, for HPE (Gen10 DL325), the _SUN is attached
to the NIC device, whereas for Dell (R640/R6515/R6615) and Cisco (UCSC-C220-M5SX),
the _SUN is on the first parent pcieport.

We still fallback to pci_get_hotplug_slot() to handle the s390 case and
maybe some other coner cases (_SUN on grand parent device that is not a
bridge ?).
2024-07-21 18:36:37 +01:00
Luca Boccassi
7b5c38a91d test: override blocking localed policy in TEST-73-LOCALE
On Debian and derivatives writing calls to localed are blocked as other
tools are used to change settings, override that policy for the tests
2024-07-21 16:30:57 +01:00
Vasiliy Kovalev
23f5f82756 hwdb: fix MXC6655 accelerometer mount matrix for Aquarius Cmp NS483
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
2024-07-21 16:29:11 +01:00
Alain Greppin
a2ae7ed7d0
systemd.dnssd does not handle local requests (#32991)
systemd.dnssd does not handle local requests

Fixes https://github.com/systemd/systemd/issues/32990
2024-07-21 12:48:56 +01:00
Mike Yuan
c26948c6da core/service: destroy runtime data when Type=oneshot services exit
Currently, we have a bunch of Type=oneshot + RemainAfterExit=yes
services that make use of credentials. When those exits, the cred mounts
remain established, which is pointless and quite annoying. Let's
instead destroy the runtime data on SERVICE_EXITED, if no process
will be spawned for the unit again.
2024-07-21 12:43:51 +01:00
Mike Yuan
8b17371b61 core/unit: add one assertion for u->manager 2024-07-21 12:43:51 +01:00
Luca Boccassi
9d962e370c
Merge pull request #33790 from YHNdnzj/run-exec-flags
run: clean up ExecCommandFlags serialization
2024-07-21 11:44:20 +01:00
ShreyasMahangade
db708fc9ba
timedatectl: setting set_local_rtc to 1 will throw Warning as well, use log_warning() (#33489)
Previously only running `timedatectl` it was showing warning regarding the dangers of setting RTC to local TZ.
Now similar warning is also flashed when `set-local-rtc 1`.
2024-07-20 19:07:30 +02:00
Dominique Martinet
8da20e3fe2 meson: fix missing failure if bpf-framework was enabled
If building with clang and clang does not support bpf, then enabling
-Dbpf-framework=enabled would silently drop the feature (even printing
bpf-framework: enabled in the meson build recap, and no message anywhere
that'd hint at the failure!)

This is unexpected, so add check to fail hard in this case.

All other code paths (gcc, missing bpftool) properly check for the
option, but it is not as easy for a custom command so check explicitly
2024-07-20 15:59:34 +02:00
Lennart Poettering
4b752770ca upate TODO 2024-07-20 15:04:32 +02:00
Mike Yuan
db12f84327
run: clean up ExecCommandFlags serialization
The current behavior is actually OK, since use_ex_prop = !arg_expand_environment,
but that's very implicit and using STRV_MAKE() this way feels icky.
Let's make this more readable, by using exec_command_flags_to_strv().
2024-07-20 09:37:34 +02:00
Mike Yuan
05c754bc7f
exec-util: modernize exec_command_flags_{to,from}_strv
- Rename ret params following our coding style
- Use assertion where appropriate
- Use BIT_FOREACH()
2024-07-20 09:37:07 +02:00
Ronan Pigott
09a8a0d023 zsh: update varlinkctl completions
correct redundant or mismatched tags and fill the argument field of
curcontext because _regex_words does not do that for us.

The _complete_help text now looks much more reasonable most of the time:

$ varlinkctl call /run/systemd/resolve/io.systemd.Resolve ^Xh
tags in context :completion::complete:varlinkctl::
    argument-rest  (_arguments _varlinkctl)
tags in context :completion::complete:varlinkctl-call:method:
    varlink-methods  (_varlinkctl_cmd _varlinkctl_command _arguments _varlinkctl)

Fixes: af63b4b769 ("zsh: add varlinkctl completions")
2024-07-19 23:07:37 +02:00
Lennart Poettering
e846854172 execute: add FIXME comment
As requested by @YHNdnzj:

https://github.com/systemd/systemd/pull/33707#discussion_r1684055699
2024-07-19 18:59:01 +02:00
Ronan Pigott
af63b4b769 zsh: add varlinkctl completions 2024-07-19 17:06:17 +02:00
Daan De Meyer
518ea76ecd docs: Document how to do stable releases 2024-07-19 16:33:36 +02:00
Lennart Poettering
32dee192a6
Merge pull request #33707 from poettering/terminal-size-by-ansi-seq
pid1: try to initialize terminal dimensions from data gathered via ANSI sequences + many clean-ups/refactorings
2024-07-19 14:35:55 +02:00
Daan De Meyer
70510bf282 mkosi: Bump default device timeout a little
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.
2024-07-19 14:20:39 +02:00
Kai-Chuan Hsieh
643347ed61 hwdb: Add mic mute key mapping for Dell Pro Rugged series 2024-07-19 11:46:42 +02:00
Lennart Poettering
16044277e9 pid1: use $COLUMNS info in status_vprintf()
This way, we can work around the fact that "struct winsize" for
/dev/console might not be initialized the moment we open the device.
2024-07-19 11:44:05 +02:00
Lennart Poettering
b411228199 main: set $COLUMNS/$ROWS for PID 1 based on /dev/console data
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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
0ea4198f0a terminal-util: add recognizable error if cols/rows of tty are initially not 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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
ad2fa21f83 terminal-util: extend timeout on background color request
I managed to hit the timeout a couple of times inside of slow qemu.
Let's increase it a bit to 1/3s
2024-07-19 11:44:04 +02:00
Lennart Poettering
abe8e99ee6 terminal-util: try to avoid reading more from terminal than we need in get_default_background_color() 2024-07-19 11:44:04 +02:00
Lennart Poettering
e2d66781ee exec-invoke: user EBADF where appropriate 2024-07-19 11:44:04 +02:00
Lennart Poettering
2cd19499a0 tree-wide: acquire /dev/console lock around any attempts to reset TTY 2024-07-19 11:44:04 +02:00
Lennart Poettering
dffbe1d152 terminal-util: teach resolve_dev_console() to deal correctly with /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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
4a24cc859f terminal-util: move lock_dev_console() here
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.
2024-07-19 11:44:04 +02:00
Lennart Poettering
c06b84d816 man: clarify what TTYReset= and TTYVTDisallocate= do and do not do regarding screen clearing 2024-07-19 11:44:04 +02:00
Lennart Poettering
56ea3c262c units: bring agetty command lines back into sync
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)
2024-07-19 11:44:04 +02:00
Lennart Poettering
628c214656 exec-invoke: move terminal initialization a bit
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)
2024-07-19 11:44:04 +02:00
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