Commit Graph
37829 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 93efd9cadb Merge pull request #22778 from poettering/kernel-install-layout-rework
kernel-install/bootctl: layout fixes
2022-03-22 13:57:28 +01:00
Lennart Poettering c0f6a6a542 Merge pull request #22662 from yuwata/udev-trigger-priority
udevadm trigger: add --prioritized-subsystem option
2022-03-22 12:56:32 +01:00
Jason A. Donenfeld d328346944 random-util: use correct minimum pool size constant
The actual minimum size of the pool across supported kernel versions is
32 bytes. So adjust this minimum.

I've audited every single usage of random_pool_size(), and cannot see
anywhere that this would have any impact at all on anything. We could
actually just not change the constant and everything would be fine, or
we could change it here and that's fine too. From both a functionality
and crypto perspective, it doesn't really seem to make a substantive
difference any which way, so long as the value is ≥32. However, it's
better to be correct and have the function do what it says, so clamp it
to the right minimum.
2022-03-22 08:46:20 +01:00
Danilo Krummrich 678f2b1667 udevadm: trigger: implement --initialized-match/nomatch arguments
systemd-udev-trigger.service by default triggeres all devices regardless
of whether they were already recognized by systemd-udevd.

There are machines (especially in embedded environments) where
systemd-udev-trigger.service is configured to run at a later stage of
the boot sequence, which can lead to quite a lot of devices being
triggered although they were already recognized by systemd-udevd.

Re-triggering a lot of devices is a relatively expensive operation and
therefore should be avoided if unnecessary.

Therefore this patch introduces --initialized-nomatch, which filters out
devices that are already present in the udev database. For consistance
reasons --initialized-match is implemented as well, which filters out devices
that are *not* already present in the udev database.

Replaces #19949.
2022-03-22 15:54:10 +09:00
Yu Watanabe d8b50e5df7 sd-device-enumerator: support to list only initialized or uninitialized devices 2022-03-22 15:27:06 +09:00
Yu Watanabe 1baeee5784 udevadm trigger: introduce --type=all option 2022-03-22 15:27:06 +09:00
Yu Watanabe 873cf95c2f udevadm trigger: introduce --prioritized-subsystem option 2022-03-22 15:27:06 +09:00
Yu Watanabe 3c5cc23a93 sd-device-enumerator: introduce device_enumerator_scan_devices_and_subsystems() 2022-03-22 15:27:06 +09:00
Yu Watanabe 37cf83d9bf sd-device-enumerator: drop /sys/subsystem support
This addresses the comment by Lennart
https://github.com/systemd/systemd/pull/22662#discussion_r829799863:
> /sys/subsystem is preparation for a future that never came.
> And given that the main proponent of this left Linux kernel
> development (Kay), I doubt this will ever come. So maybe we
> should start dropping references to /sys/subsystem/ given it's
> unlikely to materialize anytime soon.
2022-03-22 15:27:06 +09:00
Yu Watanabe 95a6f969fc sd-device-enumerator: introduce device_enumerator_add_prioritized_subsystem()
If a subsystem is specified, then matching devices and their parents are
listed at first.
2022-03-22 12:29:08 +09:00
Yu Watanabe 87c3a0f9f8 sd-device-enumerator: introduce device_enumerator_sort_devices()
and devices are sorted when the iteration started.

Previously, devices added by udev_enumerate_add_syspath() ->
device_enumerator_add_device() are not sorted. This fixes the issue.
2022-03-22 11:56:18 +09:00
Yu Watanabe deac0c9c04 sd-device-enumerator: introduce device_enumerator_unref_devices() helper function 2022-03-22 11:56:18 +09:00
Yu Watanabe 9e871965a0 sd-device-enumerator: introduce sound_device_compare() and devpath_is_late_block() helper functions 2022-03-22 11:56:13 +09:00
Lennart Poettering 41f630598d kernel-install: check for /loader/entries.srel file as explicit marker for standards compliant /loader/entries directory 2022-03-22 00:34:49 +01:00
Lennart Poettering 80889bd9cc bootctl: automatically write out $BOOT/entries/standard.srel 2022-03-22 00:34:49 +01:00
Lennart Poettering a5b30e156a bootctl: generalize open_tmpfile_linkable() use a bit
We want FILE* here, instead of a plain fd. Let's generalize this in
tmpfile-util.c, so we can reuse it later easily.
2022-03-22 00:34:48 +01:00
Lennart Poettering b72676e7a0 bootctl: load /etc/kernel/install.conf's $layout field, too
bootctl so far tried to determine the layout from /etc/machine-info, but
that's obsolete, and the kernel-install script never looked there. Let's
read the setting from /etc/kernel/install.conf instead, where
kernel-install actually looks.

Support for reading the field from /etc/machine-info is retained for
compat.

This means we'll now read /etc/machine-id, /etc/machine-info and
/etc/kernel/install.conf, and read the machine ID from the former too
and the layout setting from the latter two.
2022-03-21 23:54:33 +01:00
Lennart Poettering ea29abece9 bootctl: $KERNEL_INSTALL_MACHINE_ID + $KERNEL_INSTALL_LAYOUT are deprecated
Let's add a comment about this, and generate log messages if these
fields are actually used.
2022-03-21 23:50:17 +01:00
Lennart Poettering a321e0e463 sd-event: fix creation of floating event_add_time_change() event sources
We shouldn't auto-disable event sources we create in "floating" mode.
Hence don#t use the disabling destructor for event sources.

Given that noone else has access to this event source we just allocated
anyway there's no point in explicitly disabling it before freeing it.

Follow-up for ec75e8e07a
2022-03-21 21:57:36 +00:00
Lennart Poettering db5e7d75dc journal-file: port journal_file_open() to openat_report_new()
We so far had some magic logic in place that files we open for write
with size zero are freshly created. That of course is a bogus
assumption, in particular as this code deals with corrupted file systems
which oftentimes contain zero size inodes from left-over runs.

Let's fix this properly, and actually let the kernel tell us whether it
create the file or not.
2022-03-21 18:23:44 +01:00
Lennart Poettering d120d897ec sd-journal: refuse invocation of journal_file_open() with O_RDONLY|O_CREAT 2022-03-21 18:23:44 +01:00
Lennart Poettering ca8503f168 fs-util: add openat_report_new() wrapper around openat()
This is a wrapper around openat(). It works mostly the same, except for
one thing: it race-freely reports whether we just created the indicated
file in case O_CREAT is passed without O_EXCL.
2022-03-21 18:23:44 +01:00
Luca Boccassi 7659e52397 Merge pull request #22798 from keszybz/test-output-narrow-and-timeouts
Increase timeout for a flaky test and make test names shorter to avoid line wrapping in output
2022-03-21 14:13:22 +00:00
Zbigniew Jędrzejewski-Szmek 9b01798b98 basic/strv: avoid potential UB with references to array[-1]
"""
Given an array a[N] of N elements of type T:
- Forming a pointer &a[i] (or a + i) with 0 ≤ i ≤ N is safe.
- Forming a pointer &a[i] with i < 0 or i > N causes undefined behavior.
- Dereferencing a pointer &a[i] with 0 ≤ i < N is safe.
- Dereferencing a pointer &a[i] with i < 0 or i ≥ N causes undefined behavior.
"""

As pointed by by @medhefgo, here we were forming a pointer to a[-1]. a itself
wasn't NULL, so a > 0, and a-1 was also >= 0, and this didn't seem to cause any
problems. But it's better to be formally correct, especially if we move the
code to src/fundamental/ later on and compile it differently.

Compilation shows no size change (with -O0 -g) on build/systemd, so this should
have no effect whatsoever.
2022-03-21 13:48:00 +01:00
Zbigniew Jędrzejewski-Szmek e7949be790 Drop unused variables to fix build
This is a merge conflict between #22740 and #20156.
2022-03-21 13:30:42 +01:00
Zbigniew Jędrzejewski-Szmek 7ff9846956 Merge pull request #20156 from poettering/sysupdate
new "systemd-sysupdate" component
2022-03-21 12:06:48 +01:00
Zbigniew Jędrzejewski-Szmek 57ff888f9f test-nss-host: increase timeout
With my crappy home network the test takes 29.5s usually. But with any
tiny slowdown, it goes above the 30s limit and fails. Let's bump the
timeout to avoid spurious failures.
2022-03-21 11:43:47 +01:00
Zbigniew Jędrzejewski-Szmek 8e1fc5d939 fuzz: rename fuzz-dhcp-server-relay-message to fuzz-dhcp-server-relay
We can only relay messages, so we can make the name shorter without
losing informational value. This makes meson test output look better.
2022-03-21 11:43:47 +01:00
Zbigniew Jędrzejewski-Szmek b0a5e59622 Merge pull request #22740 from yuwata/list
tree-wide: declare iterator of LIST_FOREACH() in the loop
2022-03-21 10:52:03 +01:00
Yu Watanabe de010b0b2e strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
2022-03-19 08:33:33 +09:00
Lennart Poettering 43cc7a3ef4 sysupdate: add new component "sysupdate" 2022-03-19 00:13:55 +01:00
Yu Watanabe 80a226b26b list: make LIST_FOREACH() and LIST_FOREACH_BACKWARDS() safer 2022-03-19 08:10:29 +09:00
Yu Watanabe 03677889f0 list: declare iterator of LIST_FOREACH() in the loop 2022-03-19 08:10:29 +09:00
Lennart Poettering 922a650829 timesyncd: improve log message whe getting a reply from server
The message is misleading: it's not about synchronization but about
successful communicaiton. And it's not about "initial", but only about
first contact since we siwtched to this server.

Let's hence reword the message a bit.
2022-03-18 23:54:18 +01:00
Lennart Poettering b016e77efd timesyncd: generate a structure log message the first time we set the clock correctly
Usecase: later on we can use this to retroactively adjust log output in
journalctl or similar on systems lacking an RTC: we just have to search
for this sructured log message that indicates the first sync point and
can then retroactively adjust the incorrect timestamps collected before
that.
2022-03-18 23:54:05 +01:00
Lennart Poettering 1aa7ca2241 timesyncd: add debug logging in case we can't touch /run/systemd/timesync/synchronized 2022-03-18 23:54:01 +01:00
Lennart Poettering 1f129b7fb7 timesyncd: when updating timestamp file, use best time we know, instead of system clock
We adjust the system clock slowly after all, even if we know a more
accurate time. Use the accurate time for the timestamp.
2022-03-18 23:53:58 +01:00
Lennart Poettering 87057128e6 timesyncd: rename bool 'good' → 'talking'
THe name is just too generic. Let's pick a name that makes clear that
this is about successful communication.
2022-03-18 23:53:54 +01:00
Lennart Poettering 20c1a21066 timesyncd: don't abort packet handling if we can't save the timestamp to disk
This should not be a fatal error, and it isn't in the other place we
call this.
2022-03-18 23:53:50 +01:00
Lennart Poettering ec75e8e07a sd-event: add a single implementation of an event source that runs on clock changes
We basically had the same code in three places. Let's unify it in a
common helper function.

event_add_time_change() might be something we should add to the official
sd-event API sooner or later, given its general usefulness.
2022-03-18 23:53:34 +01:00
Lennart Poettering 7cb08ea80f timesyncd: move stuff that is not about setting the clock out of manager_adjust_clock()
Let's make sure manager_adjust_clock() is purely about setting the
clock, and nothing else.

Let's clean up logging this way. manager_adjust_clock() now won#t log
about errors, but the caller can safely do that, and do with the right
log message string.
2022-03-18 23:53:31 +01:00
Lennart Poettering adc07c2bf5 timesyncd: use CMSG_FIND_DATA() macro where appropriate 2022-03-18 23:53:27 +01:00
Lennart Poettering 5ba674cca5 timesyncd: merge some variable declarations 2022-03-18 23:53:24 +01:00
Lennart Poettering 9a8b43021b timesyncd: rebreak some comments 2022-03-18 23:53:20 +01:00
Lennart Poettering 0fd08026f8 timesyncd: add comment what bool arg is 2022-03-18 23:53:17 +01:00
Lennart Poettering 853efc39ea timesyncd: make a constant structure actually static/const 2022-03-18 23:53:13 +01:00
Lennart Poettering c696878ac0 timesyncd: cast some function invocations to void 2022-03-18 23:53:09 +01:00
Lennart Poettering aabda4f3e0 timesyncd: get rid of unnecessary 'r' assignments 2022-03-18 23:53:06 +01:00
Lennart Poettering 40c6b5143b timesyncd: use structured initialization more 2022-03-18 23:52:36 +01:00
Zbigniew Jędrzejewski-Szmek 40f35786b0 various: make parse_env_file error handling the same in various places
No big reason to do this, except that I was looking at all call sites
and it's nicer if the same style is used accross the codebase.
2022-03-18 23:26:59 +01:00