Commit Graph
90486 Commits
Author SHA1 Message Date
Luca Boccassi a8b429387a logind: cancel long-press timers when the Button is freed
The four *_long_press_event_source timers are Manager-scoped but armed
by start_long_press() with the specific Button that started the press as
their userdata. button_free() unrefs only the Button's own io and check
event sources, never these timers. If the input device backing the
Button is unplugged while a long press is in progress,
manager_process_button_device()'s REMOVE branch calls button_free() and
the still-armed timer fires up to LONG_PRESS_DURATION (5s) later,
dereferencing the freed Button as userdata (b->manager, b->seat).

Cancel each long-press timer the Button owns (matched by userdata) in
button_free().
Also unref all four sources in manager_free() instead of just the reboot
one, for symmetry at daemon teardown.

Follow-up for 952b26c75d
2026-07-03 20:15:34 +01:00
Luca Boccassi 8e70913fc1 logind: don't free live SessionDevice on duplicate TakeDevice
method_take_device() declares its local with
_cleanup_(session_device_freep), but the "device already taken" check
assigns a borrowed hashmap pointer to it and returns immediately:

    sd = hashmap_get(s->devices, &dev);
    if (sd)
            return sd_bus_error_set(error, BUS_ERROR_DEVICE_IS_TAKEN, ...);

On that return the cleanup attribute runs session_device_free() on the
still-live entry that s->devices continues to own and use.
A subsequent ReleaseDevice then fails with BUS_ERROR_DEVICE_NOT_TAKEN
and the caller is left holding a revoked fd.

Follow-up for 360179ea46
2026-07-03 20:06:21 +01:00
Luca Boccassi 19ddfe27b4 Translations update from Fedora Weblate (#42878)
Translations update from [Fedora
Weblate](https://translate.fedoraproject.org) for
[systemd/main](https://translate.fedoraproject.org/projects/systemd/main/).



Current translation status:

![Weblate translation
status](https://translate.fedoraproject.org/widget/systemd/main/matrix-auto.svg)
2026-07-03 18:27:13 +01:00
Jesse Guo 40533dcb86 po: Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 100.0% (286 of 286 strings)

Co-authored-by: Jesse Guo <jesseguotech@outlook.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/zh_CN/
Translation: systemd/main
2026-07-03 16:26:20 +00:00
Léane GRASSER 85b8fd5879 po: Translated using Weblate (French)
Currently translated at 100.0% (286 of 286 strings)

Co-authored-by: Léane GRASSER <leane.grasser@proton.me>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/fr/
Translation: systemd/main
2026-07-03 16:26:20 +00:00
Michal Čihař 6a7f0e600c po: Translated using Weblate (Czech)
Currently translated at 99.3% (284 of 286 strings)

Co-authored-by: Michal Čihař <michal@cihar.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/cs/
Translation: systemd/main
2026-07-03 16:26:20 +00:00
Luca Boccassi 1b1693633b boot: various hardening fixes flagged by kres (#42767) 2026-07-03 17:25:56 +01:00
Lennart Poettering 346d3feaea prep work for #42651 (#42871)
For some reason claude refuses to review
https://github.com/systemd/systemd/pull/42651.

Let's see if we can make it work by splitting up the big PR into smaller
ones. So here's the first one with 5 commits that should be relatively
easy to review and get merged early.
2026-07-03 17:55:53 +02:00
Lennart Poettering 61ddb06754 test: register SysInstall Varlink IDL in test-varlink-idl.c 2026-07-03 17:55:31 +02:00
Zbigniew Jędrzejewski-Szmek 977d37f575 tree-wide: add mechanism to detect missing cflags dependencies (#42866) 2026-07-03 17:54:10 +02:00
Luca Boccassi 918e8f9dd9 boot: require a minimum PE optional header size in verify_pe()
verify_pe() only checked SizeOfOptionalHeader against a SIZE_MAX wrap (a
clause that, given SizeOfOptionalHeader is a uint16_t, can never reject
anything) and never read NumberOfRvaAndSizes. But pe_kernel_info(),
pe_kernel_check_nx_compat() and pe_kernel_check_no_relocation() then read
SizeOfImage, AddressOfEntryPoint, DllCharacteristics and the base
relocation data directory entry from the optional header.

Require SizeOfOptionalHeader to be large enough to contain everything down
to the base relocation data directory entry, and require the image to
declare that many data directory entries.

Follow-up for bacc2ed0d5
2026-07-03 15:19:39 +01:00
Luca Boccassi baad1744bd boot: restore parent loaded image when initrd registration fails
linux_exec() patches the stub's own EFI_LOADED_IMAGE_PROTOCOL to point
at the loaded inner kernel, and restores the saved original only after
the entry point returns. The initrd_register() failure path returns
without restoring, leaving the firmware's protocol pointing to freed
data.

Follow-up for f405165065
2026-07-03 15:19:39 +01:00
Luca Boccassi ba0c1c617e boot: restore RW/RO memory attributes on every error
linux_exec() marks code sections RO+X for W^X and reverts them to RW+NX
in a loop just before returning, because EDK2 requires freed buffers to
be writable and non-executable or FreePages() crashes. Not every error
path is currently covered. Switch to a _cleanup_ helper so that every
return path is covered.

Follow-up for 56d19b633d
2026-07-03 15:19:39 +01:00
Luca Boccassi dc55e4a5a0 boot: check PE section against SizeOfImage
pe_locate_sections_internal() stores each matching section's VirtualSize
and VirtualAddress into PeSectionVector.memory_size/memory_offset with
only SIZE_MAX overflow guards, never checking them against the image's
SizeOfImage.

Wire up the image's SizeOfImage down to pe_locate_sections_internal()
and skip any section whose in-memory section does not fit within it.

Follow-up for fb974ac485
2026-07-03 15:19:39 +01:00
Luca Boccassi feeba8fa3b boot: bound PE section VirtualSize before zeroing the inner kernel
The inner-kernel section loader checks VirtualAddress + SizeOfRawData
against kernel_size_in_memory (for the memcpy), but the memzero right
after it clears up to VirtualAddress + VirtualSize, and VirtualSize is
only constrained to be >= SizeOfRawData.

Reject a VirtualAddress + VirtualSize that overflows or exceeds
kernel_size_in_memory, mirroring the existing SizeOfRawData checks.

Follow-up for cab9c7b5a4
2026-07-03 15:19:39 +01:00
Luca Boccassi ecf3f5056a boot: reject inner kernel entry point outside the image
pe_kernel_info() returned AddressOfEntryPoint (and the .compat section
entry_point) straight from the PE header with no check against
SizeOfImage. Since cab9c7b5a4 the stub calls the inner kernel directly
as ImageBase + entry_point, and only EFI_SIZE_TO_PAGES(SizeOfImage) pages
are allocated for it.

Follow-up for cab9c7b5a4
2026-07-03 15:19:39 +01:00
Luca Boccassi 7378b51f66 boot: don't unquote an empty value in line_get_key_value()
de0da85d41 switched the unquote check to strchr8(QUOTES, value[0]),
which is not equivalent to the old explicit comparison for an empty
value: strchr8(), like strchr(3), returns a pointer to the haystack's
terminating NUL when the needle is '\0', so strchr8(QUOTES, '\0') is
non-NULL. For a line whose separator is the last byte (e.g. "ID=") the
split leaves value[0] == '\0' and line[linelen - 1] == '\0' too, so both
conjuncts hold and value++ steps one byte past the value's terminator.

Follow-up for de0da85d41
2026-07-03 15:19:39 +01:00
Luca Boccassi 7b7599b72d boot: initialize return parameters on zero-length EFI variable read
When a variable exists but is empty, the initial size-query
GetVariable() in efivar_get_raw_full() returns EFI_SUCCESS instead of
EFI_BUFFER_TOO_SMALL: the zero-length payload already "fits" the
zero-length query buffer. The helper returns success, but does not
initialize the return parameters.
Handle a couple of corner cases by checking the return size.

Follow-up for a409607489
2026-07-03 15:19:38 +01:00
Luca Boccassi 3bcd707d56 boot: make device_path_next_node() robust against malformed zero-length nodes
device_path_next_node() advances by the current node's Length field,
which per the EFI device path protocol includes the 4-byte node header;
a well-formed node is therefore at least sizeof(EFI_DEVICE_PATH) bytes
long. A malformed node with Length < sizeof(EFI_DEVICE_PATH), in
particular Length == 0, makes the helper return its input pointer
unchanged.

Advance by at least sizeof(EFI_DEVICE_PATH).

Follow-up for 5080a60a71
2026-07-03 15:19:38 +01:00
Lennart Poettering 138829b784 sysupdate: split out url config parser into new file
These are located at two distinct places, and are very similar, let's
put them in a common place.

This is preparation for reusing them later.
2026-07-03 16:09:49 +02:00
Lennart Poettering 55127751cc sysupdate: rename read_definitions() → read_transfers()
This function only reads the .transfer files, hence give it a precise
name.
2026-07-03 16:09:49 +02:00
Lennart Poettering 8a502c4a76 sysupdate: split out reading of feature files into separate helper
This is preparation for later adding a per-component metadata file, so
that we can have nicely symmetric functions for this.
2026-07-03 16:09:49 +02:00
Lennart Poettering 922849aa7e sysupdate: align macro backslashes like we usually do 2026-07-03 16:09:49 +02:00
Lennart Poettering 5275695271 sysupdate: replace local specifier_table[] by common system_and_tmp_specifier_table[]
It's byte-by-byte exactly the same thing, hence drop the local copy.
2026-07-03 16:09:49 +02:00
Lennart Poettering ea21c6d75f sysupdate: drop redundant ()
Just a tiny simplification
2026-07-03 16:09:49 +02:00
Zbigniew Jędrzejewski-Szmek 713a2cf79c test-socket-util: convert to new ASSERT macros
Replace assert_se() with the typed ASSERT_* macros throughout, matching
the conversions done across the rest of src/test/.
2026-07-03 15:09:03 +01:00
Lennart Poettering 79c6e4fed2 Add varlink interface for sysinstall (#42261)
Allow graphical installers to use system sysinstall. This will be used
by gnome-setup to install GNOME OS and ideally installers of other
distributions talk to the same varlink interface.
2026-07-03 16:04:25 +02:00
Yu Watanabe 738884d9f7 ci/build-test: add build test for -Dsystemd-multicall-binary=true 2026-07-03 21:50:45 +09:00
Yu Watanabe 5280cd7bdb tree-wide: check if necessary cflags dependencies are set
This makes each `foo_cflags` dependency define a `SYSTEMD_CFLAGS_MARKER_FOO`
macro, and checks if the macro is set when headers provided by external
libraries are included.

With this, we can fail fast at compile time if necessary `_cflags`
dependencies are omitted in meson.build. Missing dependencies found by this
mechanism have been added across the tree.
2026-07-03 21:50:45 +09:00
Yu Watanabe 4c5cbc970a meson: merge two libelf-related clfags dependencies
Both libraries are used only by elf-utils.c.
We can merge them.
2026-07-03 21:50:45 +09:00
Yu Watanabe cff424864d meson: merge three glib cflags dependencies
They are always used together, and only used by a unit test.
Fine-graded cflags dependencies are not necessary.
2026-07-03 21:50:45 +09:00
Yu Watanabe dc28de0eaa meson: do not pass space-separated list of libraries
It was not clear that which version was returned by
tpm2.version().
Let's explicitly check dependency one-by-one.
2026-07-03 21:50:45 +09:00
Yu Watanabe e51a0122b4 meson: use tpm2_cflags dependency rather than tpm2 2026-07-03 21:50:45 +09:00
Yu Watanabe 0f607da249 pull: introduce pull-forward.h 2026-07-03 21:49:02 +09:00
Yu Watanabe 09859dbc9f tree-wide: drop unnecessary header inclusions 2026-07-03 20:27:30 +09:00
Julian Sparber 2acdbae8eb test: Add basic test for sysinstall varlink interface
This adds a basic test for the newly added varlink interface of
sysinstall.
2026-07-03 12:19:03 +02:00
Julian Sparber c17d0c7e85 sysinstall: Add varlink interface
Allow graphical installers to use system sysinstall.
This will be used by gnome-setup to install GNOME OS and ideally installers
of other distributions talk to the same varlink interface.
2026-07-03 11:16:46 +02:00
Julian Sparber 98b875b2ac sysinstall: Look for valid kernel image before installing
Instead of failing the installation after creating the partitions and
doing almost the entire installation, and then failing if we don't have
a kernel image. Look for it before we start doing modifications to the disk.
This way we tell the user as soon as possible that we can't install the
OS because of the missing kernel image.
2026-07-03 11:16:46 +02:00
Yu Watanabe 0d06dbabc3 include: do not override kernel headers with libaudit headers
Overriding <linux/audit.h> to implicitly include <libaudit.h> turns out to
be problematic. Because <linux/audit.h> is pulled in by various other kernel
headers, any source file including those kernel headers indirectly ends up
depending on <libaudit.h>, even if the executable or library being built
does not require libaudit at all.

Let's drop the override header and include <libaudit.h> only where explicitly
needed. This also moves the fallback definitions of AUDIT_SERVICE_* and
MAX_AUDIT_MESSAGE_LENGTH to libaudit-util.h.
2026-07-03 17:25:34 +09:00
Luca Boccassi d06d8a232b boot: reject GPT headers with SizeOfPartitionEntry below the minimum
Commit 0cf5f816f2 replaced the original lower-bound check

    if (h->SizeOfPartitionEntry < sizeof(EFI_PARTITION_ENTRY))
            return false;

with a multiple-of check

    if ((h->SizeOfPartitionEntry % sizeof(EFI_PARTITION_ENTRY)) != 0)
            return false;

to additionally require the entry size to be a multiple of 128. The
modulo test is however also satisfied by SizeOfPartitionEntry == 0, so a
GPT header advertising a zero entry size now passes verify_gpt().

Restore the lower bound in addition to the multiple-of check, so the
entry size must be at least sizeof(EFI_PARTITION_ENTRY) and a multiple of
it (128 bytes).

Follow-up for 0cf5f816f2
2026-07-03 09:13:48 +01:00
Daan De Meyer d04fbcf956 tree-wide: get rid of backslashes in file names
File names containing backslashes cannot be checked out on Windows,
are not handled properly by build systems such as buck, and are awkward
to work with in general, so store the \x2d slice units under sanitized
file names, and rename them to the real unit name on install via a new
optional "name" key in the units list.

The fuzz-unit-file corpus sample is renamed as well; its file name is
not meaningful to the fuzzer, and dropping the backslash means it is no
longer skipped by the meson workaround for
https://github.com/mesonbuild/meson/issues/1564, so it runs as a
regression test again.
2026-07-03 10:10:09 +02:00
Yu Watanabe 193749a52e journal: move audit-type.[ch] and related generators to src/journal
It is only used by systemd-journald and own unit test.
2026-07-03 17:07:49 +09:00
Luca Boccassi b7769aa34e machined: drop superfluos 'supervisor' varlink input parameter for register method
The supervisor is derived from the caller's socket in D-Bus, and it is
not an input parameter. Do the same in varlink.

Follow-up for 97754cd14d
2026-07-03 10:07:05 +02:00
Zbigniew Jędrzejewski-Szmek 8c4218ab9f core: add all manager timestamps to metrics report (#42842)
These are all very useful for establishing the health of a fleet, so
export them too

Follow-up for 0b0db27050
2026-07-03 10:06:43 +02:00
dongshengyuan 21de611f69 calendarspec: warn on weekday/date conflict in systemd-analyze and systemd-run
When a fixed date (e.g. 2027-01-01) is paired with a weekday constraint
(e.g. Thu) that does not match, the timer silently never elapses.

Add calendar_spec_from_string_full(..., warn_on_weekday_mismatch) so
user-facing tools can opt in to a log_warning() at parse time:
- systemd-analyze calendar: uses _full(true)
- systemd-run --on-calendar: uses _full(true)
- .timer OnCalendar=: uses log_syntax() with file/line context

Add test_calendar_spec_weekday_conflict(): forks a child with stderr
captured in a memfd via pidref_safe_fork_full(), verifies the warning
is emitted for conflicting specs and suppressed for valid ones.

Fixes: #40350
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
2026-07-03 07:39:49 +02:00
Lennart Poettering 9d37c618ee tpm2: optionally disable TPMA_NV_ORDERLY for NvPCRs (#42848) 2026-07-03 07:18:02 +02:00
Frantisek Sumsal 7273d38335 test: ignore fails when the formatted timezone differs from the current one
When formatting a timestamp the C API takes into account historical data
from tzdata, so it returns a date strings with a historically-correct
timezone abbreviation. However, tzname[] doesn't do this and it returns
the most recent abbreviation for the given zone.

For example, according to tzdata America/Cancun switched from EST/EDT to
CST/CDT on 1998-08-02:

Zone America/Cancun     -5:47:04 -      LMT     1922 Jan  1  6:00u
                        -6:00   -       CST     1981 Dec 26  2:00
                        -5:00   -       EST     1983 Jan  4  0:00
                        -6:00   Mexico  C%sT    1997 Oct 26  2:00
                        -5:00   Mexico  E%sT    1998 Aug  2  2:00
                        -6:00   Mexico  C%sT    2015 Feb  1  2:00
                        -5:00   -       EST

So, formatting a timestamp from this time will yield a string with the
EDT timezone:

$ TZ=America/Cancun date -d "@902035565"
Sun Aug  2 01:26:05 EDT 1998

But using tzname[] (or strptime %z) shows the most recent data, where
America/Cancun uses EST (and doesn't use DST anymore, hence
tzname[1]=CDT that glibc remembers from the previous zone epoch):

$ TZ=America/Cancun ./tz
{EST, CDT}

This means that when we parse the formatted timestamp back we don't use
the historical timezone data, so we might end up with a different
offset:

TZ=America/Cancun, tzname[0]=EST, tzname[1]=CDT
@902035565603993 → Sun 1998-08-02 01:26:05 EDT → @902039165000000 → Sun 1998-08-02 01:26:05 CDT
src/test/test-time-util.c:452: Assertion failed: Expected "ignore" to be true
Aborted                    (core dumped) build-local/test-time-util

Instead of adding exceptions for every single timezone that switched
between different offsets in the past, let's address this a bit more
generally and skip the check if the parsed timezone doesn't match any of
the current timezones - this still keeps the check that the time
difference in such case is exactly one hour, so its effect should be
limited mostly to DST-related changes.

Resolves: #37684
2026-07-03 07:23:30 +09:00
Yu Watanabe 2d372e2a34 Improve OpenSSL 4 support (#42843) 2026-07-03 07:20:48 +09:00
Lennart Poettering b19ef189ee bootctl: expose --esp-path/--boot-path/--make-entry-directory via Varlink (#42838)
The Install/Unlink/Link/LinkAuto Varlink methods always auto-discover
the ESP and XBOOTLDR partitions and Install always runs
make-entry-directory in auto mode, so IPC callers cannot match what the
CLI verbs do with `--esp-path`, `--boot-path` and
`--make-entry-directory`. Add optional `espPath`, `xbootldrPath` and
`makeEntryDirectory` parameters that feed into the same code paths the
CLI already uses.
2026-07-02 21:56:57 +02:00
Lennart Poettering 805742a9c5 Allow systemd to be built as as single statically-linked binary (#42820)
The idea is that we can build a container by building a single-binary
systemd:
```console
$ meson setup build-static --default-library=static --prefer-static --auto-features=disabled -Dbuild-static=true -Dsystemd-multicall-binary=true && ninja -C build-static systemd
$ mkdir /var/tmp/container/usr/lib -p
$ cp build-static/systemd /var/tmp/container/usr/lib/
$ echo 'ID=quick' >/var/tmp/container/usr/lib/os-release
$ systemd-nspawn --restrict-address-families=af_unix --register=no --private-users=managed -D /var/tmp/container/ /usr/lib/systemd
░ Spawning container container on /var/tmp/container.
░ Press Ctrl-] three times within 1s to kill container; two times followed by r
░ to reboot container; two times followed by p to poweroff container.
Selected user namespace base 1855193088 and range 65536.
systemd 262~devel running in system mode (-PAM -AUDIT +SELINUX -APPARMOR +IMA +IPE +SMACK -SECCOMP -GCRYPT +GNUTLS +OPENSSL -ACL +BLKID +CURL -ELFUTILS -FIDO2 +IDN2 +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 -BZIP2 -LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -BTF -XKBCOMMON +UTMP -LIBARCHIVE)
Detected virtualization systemd-nspawn.
Detected architecture x86-64.
Detected first boot.

Welcome to Linux!

Initializing machine ID from container UUID.
Failed to open netlink, ignoring: Address family not supported by protocol
Applying preset policy.
Populated /etc with preset unit settings.
Unit default.target not found.
Falling back to graphical.target.
Mount unit not supported, skipping *MountsFor= dependencies.
Queued start job for default target graphical.target.
[  OK  ] Reached target sysinit.target.
[  OK  ] Reached target basic.target.
System is tainted: unmerged-bin:var-run-bad
[  OK  ] Reached target multi-user.target.
[  OK  ] Reached target graphical.target.
Startup finished in 61ms.
```
The container can be reloaded with SIGTERM, powered off with SIGRTMIN+4,
etc. SIGRTMIN+5 should cause a reboot but it currently fails:
```
...
Rebooting.
Container container is being rebooted.
Failed to attach root directory: Invalid argument
Failed to receive mount namespace fd from outer child: Input/output error
```
It's a bug … somewhere, but probably not caused by the linking changes
being done here.
2026-07-02 21:56:27 +02:00