Commit Graph
36053 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 7f9521d5e1 Merge pull request #21225 from medhefgo/boot-cleanup
Boot cleanup
2021-11-05 14:53:47 +01:00
Luca Boccassi fac2c3e97d basic/mountpoint-util: detect erofs as a read-only FS 2021-11-05 14:02:04 +01:00
Lennart Poettering d7654742ee loop-util: reopen device node if we shortcut loop device creation
The LoopDevice object supports a shortcut: if the backing fd we are
supposed to create a loopback device of refers to a
block device alrady then we'll use it as is – if we can – instead of
setting up an unnecessary loopback device that would be pretty much
the same as its backing device.

Previously, when doing this we'd just dup() the original backing fd and
use that. But that's problematic in case O_DIRECT was set on the fd,
since we'll keep that flag set on our copy too, which means we can't do
simple, regular IO on it anymore.

Thus, let's reopen the inode in this case with the exact access flags
we'd apply if we'd actually allocate and open a new loopback device.

Fixes: #21176
2021-11-05 07:08:16 +00:00
Luca Boccassi 7544461cd0 Merge pull request #21229 from keszybz/improve-m-hint
Improve hint to use -M in various tools
2021-11-04 18:40:26 +00:00
Jan Janssen d1da890004 sd-boot: Fix efi_arch checks
efi_arch is set to whatever meson returns from host_machine.cpu_family() and
gnu_efi_arch is then set accordingly.

On x86, efi_arch == x86 and gnu_efi_arch == ia32. Surprisingly, compilation
worked (without disabling some instruction sets) and nobody ever complained
about systemd-bootia32.efi not working.
2021-11-04 18:54:31 +01:00
Jan Janssen 1840dfc327 sd-boot: Detect supported compile args
This brings the final list of compiler arguments more in line with
how meson does things. In particular, --buildtype=plain will not
add any optimizations on its own (and would have to be provided
through CFLAGS=).
2021-11-04 18:54:31 +01:00
Jan Janssen f8a738bbc0 sd-boot: Add some link flags
These flags are used by gnu-efi. Adding --no-undefined even allows
us to drop the no-undefined-symbols.sh test in favor of immediate
compile time errors.
2021-11-04 18:54:31 +01:00
Jan Janssen 1f6f233f87 sd-stub: Fix possible memory leak 2021-11-04 18:54:31 +01:00
Jan Janssen 65ff3d2626 sd-boot: Check for existence of required pe sections 2021-11-04 18:48:53 +01:00
Jan Janssen ff9d65f6ff sd-boot: Move optional header verification into verify_pe 2021-11-04 18:37:07 +01:00
Jan Janssen 785b5fcf5f sd-boot: Use FLAGS_SET 2021-11-04 18:37:07 +01:00
Jan Janssen a8a7723ba9 sd-boot: Move flags helpers to macro-fundamental.h 2021-11-04 18:37:07 +01:00
Jan Janssen 1224d57ba5 sd-boot: Always compile with -ffreestanding and -fshort-wchar
This is not a hosted environment and we should not pretend otherwise
if -ffreestanding is not supported.

With EFI strings being in UCS2, it is not supported to build without
-fshort-wchar as gcc/clang default to a w_char_t size of 4 bytes.

This also makes the charset for wide chars explicit on gcc. This way
we get a nice error message if anyone ever tries to add 💩 to strings.
2021-11-04 18:37:07 +01:00
Jan Janssen 3c86dcc39c sd-boot: Save and restore console attributes
This also only writes the message on a new line if we aren't at the
beginning of one already.
2021-11-04 18:37:07 +01:00
Lennart Poettering 3663f754f1 Merge pull request #21070 from medhefgo/boot-save
sd-boot: Add support to boot last select entry
2021-11-04 17:37:12 +01:00
Lennart Poettering 71bb9594e9 Merge pull request #21030 from DaanDeMeyer/path-skipped
core: Propagate condition failed state from service to path unit.
2021-11-04 15:20:00 +01:00
Zbigniew Jędrzejewski-Szmek a4eba5d8cf update-helper: add missing loop over user units
Noticed by Luca.

shellcheck doens't catch this, and somehow it was missed in review
and testing ;(
2021-11-04 11:39:04 +01:00
Zbigniew Jędrzejewski-Szmek 10a7340a97 tree-wide: do not print hint about -M if -M is already used
(Or when -H is used, since -H and -M are incompatible.)

Note that the slightly unusual form with separate boolean variables (hint_vars,
hint_addr) instead of e.g. a const char* variable to hold the message, because this
way we don't trigger the warning about non-literal format.
2021-11-04 11:00:54 +01:00
Zbigniew Jędrzejewski-Szmek fb293b3c0f busctl: do not print hint about -M if -M is already used
(Or when -H is used, since -H and -M are incompatible.)
2021-11-04 11:00:15 +01:00
Zbigniew Jędrzejewski-Szmek 237fbb6719 shared/bus-util: make bus_log_*_error() functions functions
They were defined as macros, but they are a bit too complicated for this,
so it's getting unwieldy. We can make them functions without any loss.
2021-11-04 11:00:15 +01:00
Lennart Poettering aedec452b9 tree-wide: always use TAKE_FD() when calling rearrange_stdio()
rearrange_stdio() invalidates specified fds even on failure, which means
we should always invalidate the fds we pass in no matter what. Let's
make this explicit by using TAKE_FD() for that everywhere.

Note that in many places we such invalidation doesnt get us much
behaviour-wise, since we don't use the variables anymore later. But
TAKE_FD() in a way is also documentation, it encodes explicitly that the
fds are invalidated here, so I think it's a good thing to always make
this explicit here.
2021-11-03 23:05:26 +00:00
Daan De Meyer 12ab94a1e4 core: Propagate condition failed state to triggering units.
Alternative to https://github.com/systemd/systemd/pull/20531.

Whenever a service triggered by another unit fails condition checks,
stop the triggering unit to prevent systemd busy looping trying to
start the triggered unit.
2021-11-03 20:25:14 +00:00
Yu Watanabe 829b86bc0f Merge pull request #21217 from keszybz/debug-test-process-util
procfs-util: fix confusion wrt. quantity limit and maximum value
2021-11-04 04:03:56 +09:00
Lennart Poettering b7759c8f0a macro: make TAKE_PTR() side-effect free 2021-11-03 16:36:19 +01:00
Lennart Poettering 7950211df3 tree-wide: port more code to sigkill_wait() 2021-11-03 16:36:19 +01:00
Lennart Poettering 8f03de5323 tree-wide: port various places to use TAKE_PID() 2021-11-03 16:36:09 +01:00
Lennart Poettering 883946f0d2 process-util: rework TAKE_PID() to be side-effect free 2021-11-03 15:57:02 +01:00
Lennart Poettering 2c1612100d process-util: wait for processes we killed even if killing failed
The processes might be zombies in which case killing will fail, but
reaping them still matters.
2021-11-03 15:57:02 +01:00
Lennart Poettering a70877d881 test: add test that ensures TAKE_FD() works as it should 2021-11-03 15:57:02 +01:00
Zbigniew Jędrzejewski-Szmek 384c2c3239 Make pager_open() return void 2021-11-03 15:24:56 +01:00
Lennart Poettering 90d59676b3 fd-util: make TAKE_FD free of double evaluation
Better be safe than sorry.
2021-11-03 15:22:18 +01:00
Zbigniew Jędrzejewski-Szmek 028f7d3ac6 manager: fix confusion when to send READY=1
I got the logic reversed in 6d93265955.
Let's just remove the conditionalization of the status message: if we're
sending something, we might just as well always attach READY=1, the extra
few bytes don't make much of a difference.

FWIW, it seems that this bug didn't cause problems, probably because we'd send
READY=1 either from user_manager_send_ready() or from a later call to
manager_send_ready().
2021-11-03 11:32:31 +01:00
Zbigniew Jędrzejewski-Szmek d4341b76d0 tree-wide: drop "f" from sd_notify() calls with a static string
If we don't need to do any formatting, let's optimize things a bit.
2021-11-03 11:29:49 +01:00
Zbigniew Jędrzejewski-Szmek d7737416f5 journald: modernize code to send notifications
No change except making things a bit less verbose.
2021-11-03 11:29:49 +01:00
Zbigniew Jędrzejewski-Szmek 4bf4f50faa tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1
Most sd_notify() calls are like log_info() — the result is only informative
and if they fail, it's best ignore this. But if a call with READY=1 fails,
the unit may enter a failed state, so we should warn about this. Similarly
for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting
resources.
2021-11-03 11:29:49 +01:00
Zbigniew Jędrzejewski-Szmek 6434a83d01 test-process-util: also add EROFS to the list of "good" errors
It is only added in the one place where we actually try to set the
setting to a new value. Before we were testing if we can set to it the
existing value, which was a noop. We could still get a permission error,
but this is the first place where we would propagate EROFS.
2021-11-03 09:39:16 +01:00
Zbigniew Jędrzejewski-Szmek c3dead53d5 procfs-util: fix confusion wrt. quantity limit and maximum value
From packit/rawhide-arm64 logs:
Assertion 'limit >= INT_MAX || get_process_ppid(limit+1, NULL) == -ESRCH' failed at src/test/test-process-util.c:855, function test_get_process_ppid(). Aborting.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

The kernel has a few different limits. In particular kernel.threads-max can be
set to some lower value, and kernel.pid_max can be set to a higher value. This
is nice because it reduces PID reuse, even if the number of threads that is
allowed is limited. But the tests assumed that we cannot have a thread with
PID above MIN(kernel.threads-max, kernel.pid_max-1), which is not valid.

So let's rework the whole thing: let's expose the helpers to read
kernel.threads-max and kernel.pid_max, and print what they return in tests.
procfs_tasks_get_limit() was something that is only used in tests, and wasn't
very well defined, so let's drop it.

Fixes #21193.
2021-11-03 09:36:08 +01:00
Yu Watanabe ab7b261663 Merge pull request #21210 from yuwata/network-dhcp-server-introduce-router-setting
network: dhcp-server: introduce Router= setting to specify router address
2021-11-03 12:41:34 +09:00
Lennart Poettering 2f2cdd7250 percent-util: clamp percent range before converting to 2^32 scale
Let#s better be safe than sorry and clamp the input, so that we don't
hit overflow issues.
2021-11-03 12:41:17 +09:00
Lennart Poettering 4768cc450d missing: add missing header inclusions
These headers should work without any manual header inclusion.
2021-11-03 12:41:01 +09:00
Yu Watanabe 59aa622013 network: dhcp-server: introduce Router= setting to specify router address
Closes #21202.
2021-11-03 03:15:00 +09:00
Franck Bui be0cc2ce6c test-keymap-util: always use kbd-model-map we ship
This test makes assumptions on the availability of some mappings contained in
kbd-model-map and therefore strongly relies on the version shipped by
upstream. IOW the test is likely to fail if it's installed on a system with a
more comprehensive kbd-model-map.

This patch makes the upstream kbd-model-map file available via a symlink in
test/testdata/test-keymap-util dir and makes sure that this specific version is
always used by test-keymap-util regardless of whether the test is installed and
run on a different system or directly run (optionally via meson) from the
project working dir.
2021-11-02 16:48:55 +01:00
Yu Watanabe 60b4af930e network/veth: also set MTU for peer interface
Fixes #21206.
2021-11-02 12:25:15 +09:00
Yu Watanabe aa5a0f959c sd-dhcp6-client: simplify code a bit
Also this adds a note.
2021-11-01 23:13:08 +09:00
Yu Watanabe 0936c189c9 sd-dhcp6-client: do not implicitly cast to boolean 2021-11-01 23:13:08 +09:00
Yu Watanabe e79b4b8534 sd-dhcp6-client: introduce dhcp6_lease_{get,set}_clientid() 2021-11-01 23:13:08 +09:00
Yu Watanabe 65457c17e6 sd-dhcp6-client: shorten code a bit 2021-11-01 23:13:08 +09:00
Yu Watanabe 4f81f0d241 sd-dhcp6-client: prefix variables which store results with "ret_" 2021-11-01 23:13:08 +09:00
Yu Watanabe d3aa9d6a80 sd-dhcp6-client: update log messages 2021-11-01 23:13:08 +09:00
Yu Watanabe 7e6abd25f4 Merge pull request #21200 from yuwata/sd-dhcp6-client-server-address
sd-dhcp6-client: introduce sd_dhcp6_lease_get_server_address()
2021-11-01 21:04:48 +09:00