93958 Commits
Author SHA1 Message Date
Adrian Reber b446dda9ad shared: add a PE addon writer
Builds a systemd-stub addon from the addon stub we ship, with an
optional .cmdline and .initrd section and the same .sbat section ukify
adds, using the PE writer.
2026-11-04 07:13:41 +00:00
Adrian Reber f6b4e316e8 initrd-cpio: add a variant that returns the credentials cpio in memory
systemd-firstboot wants to wrap the archive into a PE section rather
than pass a file to a VMM, hence split the memory part out of the temp
file writer, which becomes a wrapper around it.
2026-11-04 07:13:40 +00:00
Adrian Reber ad151a463d shared: move the mtools wrappers out of mkfs-util into vfat-util
repart populates vfat file systems through mtools, as we have no vfat
library, and the wrappers for that lived as static functions in
mkfs-util.c, next to the mkfs invocation. systemd-firstboot is about to
need the same thing for placing a file in the ESP of an image without
mounting it. Move the code into vfat-util.c with a small public API:
copying a whole tree (what repart did so far), creating a directory
with its parents, and copying a single file. The functions take the
image path and the byte offset of the file system in it, so that a
partition inside a larger image can be addressed. That mtools is doing
the work underneath, and that the offset is passed to it with its "@@"
syntax, stays an implementation detail that could be replaced.

The helper that formats $SOURCE_DATE_EPOCH for child processes is
needed by both callers now, hence move it next to
parse_source_date_epoch().

Add a test that writes into a vfat image at an offset and reads the
result back with mtype.
2026-11-04 07:13:40 +00:00
Yu Watanabe 95d38e10a6 network: stop use of SYNTHETIC_ERRNO()
Follow-up for c7542b29bc.
Follow-up for 87b2278ee2.
Addresses https://github.com/systemd/systemd/pull/44629#discussion_r4463122925.
Addresses https://github.com/systemd/systemd/pull/44629#discussion_r4463123004.
2026-11-04 14:58:59 +09:00
Yu Watanabe 288aafab54 core/dbus-unit: propagate ENOMEM with the corresponding bus error
Follow-up for 73ce8bcf16.
Addresses https://github.com/systemd/systemd/pull/44629#discussion_r4463122829.
2026-11-04 14:58:59 +09:00
Yu Watanabe 7e90bf7501 systemctl: several follow-ups for wait command (#44567) 2026-11-04 14:26:28 +09:00
Yu Watanabe de3a0977e1 Log correct errors (#44629) 2026-11-04 13:57:55 +09:00
Yu Watanabe dc992d3108 sd-bus: don't assert_return on closing/closed bus state (#44580) 2026-11-04 13:54:21 +09:00
Nick Rosbrook 7ad5ff04a9 test: use simple certificate chain in systemd-report test
Ubuntu now ships upki, and contains patches for openssl4, curl, and
others, to perform extra certificate validation. One consequence of this
is that using a self-signed cert for both the server's identity, and the
client's trust anchor fails validation.

To fix this, build a simple CA and sign a certificate for the server,
and use the CA cert as the client trust anchor.

This fixes the test on newer Ubuntu, but should still work everywhere.
2026-11-04 11:21:04 +09:00
Noa 408233f57c zsh: escape : in xkb options completions 2026-11-04 11:02:27 +09:00
Yu Watanabe 923be8422a Constants for paths (#44627) 2026-11-04 10:16:08 +09:00
Yu Watanabe f9999302e8 clang-tidy: flag direct open(), openat() and creat() calls (#44603)
The tree opens files via the xopenat() family, but nothing stops new
code from calling open() directly, and the repart manifest code already
did so after the migration. Let's port the tests, fuzzers and the two remaining
direct calls in chase and repart to xopenat(), and then add open(), openat()
and creat() to bugprone-unsafe-functions so that clang-tidy reports new
direct calls.

The functions that implement xopenat() and fd_reopen(), the seccomp tests
and the O_EMPTYPATH probe in test-fd-util.c keep calling the syscalls
directly and suppress the check. openat2() can't be covered, since it's a
macro for openat2_shim() and the check ignores calls from macro expansions.
2026-11-04 10:14:35 +09:00
Yu Watanabe bb4e7518f3 journald: include socket cookie in stream state file names (#44521)
journald keeps track of stream metadata in files identified by dev and
inode numbers. However for sockets, the kernel returns a number that's
truncated to 32 bits. On busy systems, that number can overflow and be
attributed to another service, which will remove the file on exit. When
journald gets restarted, when trying to restore objects, it will see
that the file is missing and emit an error: `systemd-journald[228270]: 1
unknown file descriptors passed, closing`. PID 1 will then retain the fd
and future writes from the daemon that was using that stream will end up
being stuck in the socket that nothing drains.

This PR fixes this by appending `SO_COOKIE` to the name of the stream.
If supports old style streams so that upgrades work and older builds
will load the stream by looking only at the dev and inode, so that
rollbacks work.
2026-11-04 08:44:52 +09:00
Pat Riehecky f698e5a70f hostnamed: allow marking serial number as rubbish
Some systems, Supermicro in particular, place the serial number on the
Baseboard (DMI type 2) rather than System Information (DMI type 1).

Two new flags for hwdb are added:
* ID_PRODUCT_SERIAL_IS_RUBBISH
* ID_BOARD_SERIAL_IS_RUBBISH

Tested on:
* Supermicro X10DRW-iT
* Supermicro X11SPW-CTF

Signed-off-by: Pat Riehecky <riehecky@fnal.gov>
2026-11-04 08:40:16 +09:00
Zbigniew Jędrzejewski-Szmek a9e9ccf511 core: don't log stale errno for unparsable rules
A matching failure of sscanf() does not set errno, so the journal entry
carried whatever errno was left over by earlier calls.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 73ce8bcf16 core: don't use stale errno in bus error messages
The correct error value is in 'r', not in 'errno'. "%m" in the
error text printed an unrelated value.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 11a6bbcce8 core: log correct error after selinux calls
The messages always said "Operation not permitted" and -EPERM was
returned whatever the real error was.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek e0167d2bfd core: use correct error variable 2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek e282719c27 core: drop stale %m from fallback message
fd_is_writable() returned 0, which is not an error, so %m printed whatever
errno happened to hold.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 8b4973edfd core: log correct error when move_mount() fails
move_mount() returns -1 and sets errno, so the message said "Operation not
permitted" for every failure and -EPERM was returned to the caller.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 81f76a0dde basic/lock-util: log correct error
lock_generic() returns a negative errno; the message relied on errno still
holding the value of the underlying call.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek c7542b29bc networkd: don't pass a success value as error to log_syntax()
r is 0 from the successful safe_atoi32() when the range check fails.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 7a05e65b57 networkctl: don't pass a boolean as error to log_error_errno()
r is the positive result of null_or_empty_path() here, so the journal
entry carried ERRNO=1 and the verb returned -EPERM by accident.
2026-11-04 00:33:24 +01:00
Zbigniew Jędrzejewski-Szmek 23325a6ecf networkd: don't pass word count as error, fix setting name
It's RouteMetric=, not RouteTable=. Use 'lvalue' so that the string can be
deduplicated.

When extract_first_word() returned 1 but nothing followed the separator,
the word count was passed as the error, so the message ended in
": Operation not permitted". Passing 0 to log_syntax() is OK, but passing
a positive success value is not.

Also don't pass unrelated 'r' in some other cases.
2026-11-04 00:33:24 +01:00
Yu WatanabeandAlvaro Leiva Geisse f96742e512 core/dbus: skip setting up API bus when it is already disconnected.
If it is already disconnected, we cannot setup the API bus anyway,
and shows several spurious errors for e.g. failure in
sd_bus_negotiate_creds().

Co-authored-by: Alvaro Leiva Geisse <aleivag@gmail.com>
2026-11-04 08:29:34 +09:00
Yu Watanabe 6cadc7f86b sd-bus: don't assert_return on closing/closed bus state
sd_bus_negotiate_timestamp() and sd_bus_negotiate_creds() used
assert_return() to reject calls once the bus is closing/closed. But
that state is reachable during normal operation, not just caller
misuse: a pending async call's reply callback can still run after the
bus has entered BUS_CLOSING (flushed with a synthetic error reply),
and may then try to negotiate creds/timestamps on the same bus object.

In developer-mode builds, a failed assert_return() aborts the process,
so this turns an expected race into a crash. Replace the assertion
with a plain state check that returns -EPERM, as before, without
aborting.

Fixes the following failure (the log is rebreaked):
```
systemd[1]: Failed to process message type=error sender=org.freedesktop.DBus
            destination=n/a path=n/a interface=n/a member=n/a cookie=4294967295
            reply_cookie=1 signature=s error-name=org.freedesktop.DBus.Error.Timeout
            error-message=Connection terminated: Connection timed out
systemd[1]: Failed to query API bus instance ID, not deserializing subscriptions: Connection terminated
systemd[1]: Assertion '!({ _Bool _found = 0; static const typeof(+bus->state)
            __assert_in_set[] __attribute__((__unused__)) = { BUS_CLOSING, BUS_CLOSED };
            _Static_assert((__builtin_choose_expr( !__builtin_types_compatible_p(typeof(__assert_in_set),
            typeof(&*(__assert_in_set))), sizeof(__assert_in_set)/sizeof((__assert_in_set)[0]), ((void)0))) <= 22,
            "ELEMENTSOF(__assert_in_set) <= 22"); switch (bus->state) { case BUS_CLOSING: case BUS_CLOSED:
            _found = 1; break; default: ; } _found; })'
            failed at src/libsystemd/sd-bus/sd-bus.c:385, function sd_bus_negotiate_creds(). Aborting.
systemd[1]: Caught <ABRT>, from our own process.
```
2026-11-04 08:29:34 +09:00
Zbigniew Jędrzejewski-Szmek df06b335bb networkd: simplify error gathering for RouteMetric= 2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 87b2278ee2 networkd: log correct error for an invalid NHA_OIF attribute
r is the successful result of sd_netlink_message_read_u32() here, so the
message ended in ": Success".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek bfe0dd5773 shared/microhttpd-util: don't pass GnuTLS error codes as errno
GnuTLS returns its own negative error codes, so %m printed the strerror()
of an unrelated errno value and verify_cert_authorized() returned the
GnuTLS code as if it were a negative errno. Print the GnuTLS error text
instead.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek e1728f490f shared/bpf-program: return correct error when parse_fd() fails
r is the word count returned by extract_first_word(), i.e. 1, so an
unparsable fd made bpf_program_deserialize_attachment() return success
without setting the output, and the caller inserted a NULL program into
the set.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek f5ebb445e5 shared/tpm2-util: return an error when a credential contains an embedded NUL byte
r is 0 here, the result of the successful decryption, so the refusal was
logged but pcrlock_policy_load_credential() returned success with the
output left untouched, and tpm2_pcrlock_policy_from_credentials() took the
zero-initialised policy as found.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek e1466ebfa6 shared/watchdog: drop stale %m from success message
The ping succeeded, so the journal entry read "Successfully pinged
hardware watchdog … after N attempts: Success".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek bb01e783da shared/killall: log correct error
pidref_kill() returns a negative errno, which is not necessarily reflected
in errno, for example for its synthetic -ESRCH and -EREMOTE results.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 8e19a15944 shared/mkfs-util: log and return correct error
stat() reports failures via errno, but the message used r, which is 0 from
the preceding calls. The log line said "Success" and make_filesystem()
returned 0 without ever running mkfs.btrfs.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 3df55e1e74 ptyfwd: use correct error variable
Cosmetic, but r already holds the negative errno from RET_NERRNO().
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 62f34e8cc3 test-process-util: print the real error
get_process_environ() returns a negative error, but the message printed
the unrelated errno instead.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 430d66f641 test-pressure: drop stale error from skip message
r holds the successful result of sd_event_add_memory_pressure() here, so
the message ended in ": Success".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 223bffb504 test-thp: drop stale %m from error messages
r is the THP mode returned by prctl(), not an error, and %m was
used without passing an error.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek abd1295ac7 test-fs-util: log correct error 2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek b11cae9ab1 test-copy: drop stale errno from skip message
enable_fsverity() succeeded here, so errno is unrelated to the condition.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 6edee8fac6 test-copy: log correct error 2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 830f4364de test-bus-chat: don't print stale errno
sd_bus_can_send() returning 0 is not an error, so %m printed a stale
value. A negative return was also not distinguished from "not supported".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 770e0666e8 udev: log correct error
The message printed %m without passing an error.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek cb4cc16965 sd-journal: log correct errors
fd_nonblock() returns a negative errno; the message used errno, and the
stale value was also recorded for the file and returned.

Also 'r' was set in a roundabout way in a few cases, simplify those.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 0bd0b43836 bsod: log correct error
fdopen_independent() returns a negative errno; the message used errno, and
the stale value also became the return value of the function.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 0f38ceef8f storagetm: don't pass a placeholder fd as error to log_debug_errno()
port_fd is -EBADF here by construction, so the journal entry got
a bogus errno value.
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek e5e3cb46e5 repart: log correct error for invalid subvolume flags
The two messages passed r, the word count of the enclosing
extract_first_word() loop, instead of the error returned by
subvolume_flags_from_string().
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek fb385dd6fd import: log correct error for tar_strip_suffixes()
tar_strip_suffixes() fails with -EINVAL when the name consists of nothing
but the suffix, which was reported as "Out of memory.".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 1ebf31ff37 nspawn: log correct error when mangling the slice name fails
unit_name_mangle_with_suffix() fails with -EINVAL for an empty --slice=
argument, which was reported as "Out of memory.".
2026-11-04 00:27:28 +01:00
Zbigniew Jędrzejewski-Szmek 514f779397 nspawn: log correct error 2026-11-04 00:27:28 +01:00