Commit Graph
55933 Commits
Author SHA1 Message Date
Luca Boccassi b5a7f13a42 tree-wide: bunch of fixlets raised by coverity (#38341) 2025-07-26 11:10:00 +01:00
Yu Watanabe 08cf7c70b9 fs-util: avoid overflow in MODE_TO_PTR() with MODE_INVALID
Note, currently MODE_TO_PTR() and PTR_TO_MODE() are only used in
src/udev/udev-rules.c .

Fixes CID#1548060.
2025-07-26 05:00:02 +09:00
Yu Watanabe c119eb0edc install: skip later first_word() calls if one of earlier calls passes
Prompted by CID#1587764, that is false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe 635894a493 fuzz-efi-string: add missing OOM check
Fixes CID#1610113 and CID#1610114.
2025-07-26 05:00:02 +09:00
Yu Watanabe fa43d54b55 delta: add missing error check
Follow-up for 59829bb37a.
Fixes CID#1611425.
2025-07-26 05:00:02 +09:00
Yu Watanabe 2c3b3e2fd9 ordered-set: avoid overflow
Previously, ordered_set_put_strdupv() and friends returns the number of
pushed entries, but that is potentially larger than INT_MAX (of course,
realistically, OOM is triggered in that case).

No caller uses the number of the new entries. Let's return 1 when at
least one element is added.

Fixes CID#1611523.
2025-07-26 05:00:02 +09:00
Yu Watanabe 6ce3b1fa33 test: add explicit test cases for cpu_set_add() and cpu_set_add_range()
cpu_set_add_range() is used in parse_cpu_set(), hence already tested.
But it is better to test these functions explicitly.

For CID#1611787 and CID#1611788, that should be false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe d54f1e4329 cpu-set-util: check if cpu set is already allocated
Prompted by CID#1611789, CID#1611790, and CID#1611791.
2025-07-26 04:59:58 +09:00
Luca Boccassi bcc73cafdb bootctl: automatically set --graceful when running in chroot
Installing stuff in a chroot should not fail because efivars are
not available. When running in a container touching efivars is
completely disabled, but there are some cases (recovery) where
it is needed to touch them in a chroot, so don't disable them but
avoid failing the run instead.
2025-07-25 20:44:03 +01:00
Luca Boccassi a3eb0e99d3 cgroup-util: enforce alignment of f_handle
The change in 4d2e61211d
broke armv7 where uintptr_t is 4 bytes:

/* test_id */
Assertion '((uintptr_t) _p) % alignof(uint64_t) == 0' failed at src/basic/cgroup-util.c:108, function cg_get_cgroupid_at(). Aborting.

(gdb) p (uintptr_t)fh.file_handle.f_handle % _Alignof(uint64_t)
$9 = 4

Enforce that the structure is aligned as expected

Follow-up for 4d2e61211d
2025-07-25 20:42:23 +01:00
Yu Watanabe 04a99c48d2 cpu-set-util: fix identical ternary expression
Follow-up for fe3ada076e.
Fixes CID#1611792.
2025-07-26 03:44:49 +09:00
Yu Watanabe 1f4e9f6d60 core/exec-invoke: check size of read size
Even though we do not use the read data, it is better to check the size
to prevent something spurious going.

Fixes CID#1612155.
2025-07-26 03:44:49 +09:00
Yu Watanabe 4d13e4dcbb resolved: use usec_add() at one more place
Follow-up for 8458b7fb91.
Fixes CID#1612580.
2025-07-26 03:44:49 +09:00
Luca Boccassi d6a70c1523 syscalls table: add sh (#38338) 2025-07-25 19:23:00 +01:00
Luca Boccassi a50c687b01 syscalls-table: add sh and regenerated table 2025-07-25 17:17:28 +01:00
Zbigniew Jędrzejewski-Szmek 5e405f612e meson: add instructions for adding new arch to syscall.h 2025-07-25 17:53:48 +02:00
Zbigniew Jędrzejewski-Szmek c5dcbd073e meson: use files() not find_program() for helper scripts
We went back and forth between 'prog.sh', files('prog.sh'), and
find_program('prog.sh'). We want to use files() or find_program() so that we
get a good error message if the file is missing. Behaviour of meson changed
over time, and in the past not all forms could be used in all places. For
example 0f4c4f3824 added find_program() in many
places to avoid repeated messages. But it seems that all recent meson versions
work fine with files().

find_program prints silly messages:
  Program tools/make-man-index.py found: YES
       (/home/zbyszek/src/systemd/tools/make-man-index.py)
  Program tools/meson-render-jinja2.py found: YES
       (/home/zbyszek/src/systemd/tools/meson-render-jinja2.py)
  ...
We know that those files will be found, they are part of the git checkout.
With files() this is gone and the meson output is easier to read.
2025-07-25 14:04:17 +02:00
Zbigniew Jędrzejewski-Szmek 8aedfd979f tools: make all .py program files executable
All those files are standalone programs that can be executed directly.
Some .py files were marked executable, others weren't, probably accidentally.
Mark them all as executable in preparation for subsequent changes.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek 0bf9bbecae tools: consistently use #!/usr/bin/env python3
It's ugly, but it's better to be consistently ugly.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek 0e031d5e0b meson: inline output file names
Before 7d247d3cb8, we needed the file name
twice. But now we only need it once, so no need to overcomplicate things
by defining a variable with a single use.

When a variable is used, it's also easier to make a mistake and e.g.
accidentally reuse the variable later.
2025-07-25 12:33:13 +02:00
Zbigniew Jędrzejewski-Szmek 92716a079f Logging fixlets (#38313) 2025-07-25 12:27:24 +02:00
Yu Watanabe dda9eeb081 test-sd-device: filter out dm block devices at several more places
Follow-up for 911a52b769.

Fixes #38332.
2025-07-25 11:03:31 +01:00
Luca Boccassi 9263c6f57e test: modernize test-oomd-util (#38329) 2025-07-25 11:01:32 +01:00
Nick Labich 85e9805903 sysupdate: Prevent unnecessary failure when a transfer Path is not present
Fixes https://github.com/systemd/systemd/issues/38007
2025-07-25 10:53:48 +01:00
Yu Watanabe c4ffd0a020 errno-list: fallback to use our errno name table
Some architecture specific errno may not be known by glibc.
Let's fallback to our table when strerrorname_np() returns NULL.

Fixes the following error in mips:
```
src/test/test-errno-list.c:14: Assertion failed: Expected "errno_to_name(i) == errno_names[i]", got "(null) != EINIT"
```

Follow-up for 03ccee1939.
2025-07-25 10:50:45 +01:00
Yu Watanabe b089f65676 test: modernize tests.c and tests.h
- use ASSERT_OK() and friends,
- use mkdtemp_malloc(),
- use pidref_safe_fork() and pidref_wait_for_terminate_and_check().
2025-07-25 09:10:25 +09:00
Yu Watanabe 468b10b188 test: modernize test-oomd-util
- use DEFINE_TEST_MAIN() macro,
- use ASSERT_OK() and friends,
- drop restriction that the test must run as root,
- replace sleep(2) with loop of shorter sleep and cg_is_empty(),
- applied several coding style cleanups.
2025-07-25 09:09:20 +09:00
Yu Watanabe 621998dd39 test: several fixlets for journal related failures (#38308)
Hopefully fixes #37818, #37143, #38287.
2025-07-25 08:03:08 +09:00
Luca Boccassi 0997a60aee core/dbus-manager: validate unit type before calling into service-specific methods (#38323)
Fixes #38320
2025-07-24 23:17:41 +01:00
Luca Boccassi c1fb58cc48 vmspawn: add machine types for m68k/sparc64 and default to 'none' if unknown
Qemu has a 'none' machine that can be used for very basic booting
on weird arches, just default to that unless otherwise specified
2025-07-24 17:11:14 +01:00
Luca Boccassi 50095c51fc tpm2-clear: build only if bootloader/openssl are enabled
The tpm2-clear units are only installed if tpm/bootloader/ssl are
enabled. The tpm2-setup binary/units are built and installed only
if tpm/bootloader/ssl are enabled.
Do the same for the tpm2-clear binary to keep it consistent.
2025-07-24 17:10:17 +01:00
Mike Yuan 39a8029f4e core/dbus-manager: validate unit type before calling into service-specific methods
Fixes #38320
2025-07-24 16:08:45 +02:00
Mike Yuan 5c94f12fa6 core/dbus-manager: don't ever try to dump fdstore for units not properly loaded 2025-07-24 16:07:28 +02:00
Yu Watanabe 8cfffab0e5 journal: clear cached journal storage space before vacuum journals
Otherwise, the cached storage space may be calculated based on the old
journald.conf settings.

Follow-up for 922d037f34 and
df5b3426f6.
2025-07-24 21:18:16 +09:00
Yaping Li 603916702d test-memstream-util.c: Migrate to new assertion macros
We recently added a new set of assertion macros such as ASSERT_GE, ASSERT_OK, ASSERT_EQ, ... which show not
only the expression that failed but also the values of the arguments of the expression. Let's use them.
2025-07-24 20:45:35 +09:00
Zbigniew Jędrzejewski-Szmek 56631ac8df udev: downgrade ENOMEDIUM warnings
I noticed similar warnings in many VM boots:
  fedora (udev-worker)[475]: sr0: Failed to open device node: No medium found
This particular one is from src/udev/udev-builtin-uaccess.c:125, but I think the
same principle should be used in all places: if we are ignoring errors that the
device has been removed, we should also ignore ENOMEDIUM.
2025-07-24 10:42:50 +02:00
Zbigniew Jędrzejewski-Szmek b0ca060e05 core/socket: shorten/reword message about restarted sockets
log_unit_warning() already prints the full unit name, so we don't need to say
that it is a socket unit. And in technical messages articles like "the" are
generally skipped to make the messages shorter. Use simpler tense and simpler
wording.

Example from log: fedora.local systemd[1]: systemd-initctl.socket: Socket unit
        configuration has changed while unit has been running, no open socket file
        descriptor left. The socket unit is not functional until restarted.
This is just too wordy and says "socket" four times.
2025-07-24 10:29:23 +02:00
Yaping Li 741444797f test-unit-serialize.c: Migrate to new assertion macros
We recently added a new set of assertion macros such as ASSERT_GE, ASSERT_OK, ASSERT_EQ, ... which show not
only the expression that failed but also the values of the arguments of the expression. Let's use them.
2025-07-24 07:27:58 +09:00
Yu Watanabe 5bd37b352c network/state-file: coding style fixlet
Follow-up for 168ad243cc.
2025-07-23 22:24:19 +09:00
Yu Watanabe 5489a9c409 network/state-file: ignore any errors in sd_dhcp6_lease_get_dnr()
Follow-up for 168ad243cc.

For consistency with other places.
2025-07-23 22:24:19 +09:00
Yu Watanabe 2924a6c927 network/json: ignore -ENODATA and any failures from sd_dhcp_lease_get_sip()
Addresses https://github.com/systemd/systemd/pull/38269#discussion_r2225375899.

Follow-up for 238c427aa9.
2025-07-23 22:24:19 +09:00
Zbigniew Jędrzejewski-Szmek 1fe7ebe8c2 stub: check if security override is available before using it (#38295)
Avoids fallback that requires it if it is not available. Can be dropped
once support for shim < 16 is no longer needed

Follow-up for 23d56ae890
2025-07-23 15:16:01 +02:00
Yu Watanabe fa32f4cd75 meson: crypt.h must always exist
We require at least crypt_r() exists, and it is provided since glibc-2.0
(and dropped in glibc-2.39) or by libxcrypt, and the function is
provided in crypt.h regardless it is provided by glibc or libxcrypt.
Hence, we cannot fallback to unistd.h.

This makes the condition about crypt.h more strict, and stop compilation
earlier when crypt.h does not exist.
2025-07-23 22:13:20 +09:00
Mike Yuan a6da6c9050 networkctl-config-file: validate args are valid filenames
... as opposed to full paths

Fixes #38288
2025-07-23 22:11:42 +09:00
Luca Boccassi 5115710528 stub: check if security override is available before using it
Avoids fallback that requires it if it is not available. Can
be dropped once support for shim < 16 is no longer needed

Follow-up for 23d56ae890
2025-07-23 10:29:19 +01:00
Zbigniew Jędrzejewski-Szmek dcccbe049c tree-wide: several fixlets for log message and comment (#38263) 2025-07-23 10:17:33 +02:00
Zbigniew Jędrzejewski-Szmek 15b0b6cd71 getty-generator: fine-grained execution control (#38258)
Closes #37928.
2025-07-23 09:58:27 +02:00
Luca Boccassi 23d56ae890 stub: restore compatibility for shim (< 16.0) -> UKI case
It is possible to boot directly a UKI from shim, and Fedora Cloud Base UKI
does exactly this.
This used to work fine until https://github.com/systemd/systemd/pull/37372
which broke compatibility when shim < 16.0 (no loader protocol override) is
used. Shim 15.8 is still in use in several distributions, and will be for
a long time.

Restore a part of the previous implementation, and if running with secure
boot enabled, and with shim but < 16.0, apply a security override.

Follow-up for cab9c7b5a4

Fixes https://github.com/systemd/systemd/issues/38104
2025-07-23 09:54:09 +02:00
Yaping Li 0ccc31d964 test-user-record.c: Migrate to new assertion MACROs
We recently added a new set of assertion macros such as ASSERT_GE, ASSERT_OK, ASSERT_EQ, ... which show not
only the expression that failed but also the values of the arguments of the expression. Let's use them.
2025-07-23 09:36:46 +09:00
Yaping Li e89f865157 test-web-util.c: Use ASSERT_FALSE() instead of ASSERT_TRUE() where appropriate 2025-07-23 09:36:00 +09:00