Commit Graph
88233 Commits
Author SHA1 Message Date
Yu Watanabe ffafefbcce sd-dhcp-client: replace max_request_attempts with constant macro 2026-04-24 07:40:07 +09:00
Yu Watanabe c32105081f sd-dhcp-client: introduce client_send_discover()
No functional change, just refactoring.
2026-04-24 07:40:07 +09:00
Yu Watanabe 16d08897bb sd-dhcp-client: open socket when necessary and close it when unnecessary
To make gracefully ignore unexpected messages from outside at unexpected timing.
This potentially reduces work load to handle such messages, and slightly
reduces attack surface by malicious DHCP messages.

This also makes the socket fd is owned by the relevant IO event source.

Except for the performance optimization and security hardening, this
should not change any behaviors. So, just refactoring.
2026-04-24 07:40:07 +09:00
Yu Watanabe 3817ab9e14 sd-dhcp-client: add one missing assertion
Found and suggested by Claude. Nice!
2026-04-24 07:40:07 +09:00
Yu Watanabe 6a3b0e8475 sd-dhcp-client: move the object definition to the header
Then, we can split the long sd-dhcp-client.c into small pieces later.

This also drops redundant typedef, which is also in sd-dhcp-client.h.
2026-04-24 07:40:07 +09:00
João Taveira Araújo bbadd35596 networkd: allow route table names for VRF.Table=
Allow `[VRF] Table=` to accept route table names in addition to
numeric table identifiers. These may be predefined route table names
or names configured with `networkd.conf` `RouteTable=`.

There was an earlier attempt to make `VRF.Table=` accept names in
f98dd1e707, but it wired the setting to
`config_parse_route_table()`. That parser was a `[Route]` section
parser, not a generic scalar parser for netdevs: it expected
network/route parser state and created a `Route` object. It was
therefore reverted by 40352cf0c1.

This commit replaces the uint32 parser with
`manager_get_route_table_from_string()`, the generic table parser
already used by route/rule, DHCP/RA `RouteTable=`, and WireGuard
`RouteTable=` in `.netdev` files. The VRF semantics stay
unchanged. The commit retains the existing behavior of the
deprecated `TableId=` field.

Co-developed-by: OpenAI Codex <codex@openai.com>
2026-04-23 22:06:12 +02:00
Zbigniew Jędrzejewski-Szmek 42506e6dd1 Add 'data' parameter to options and convert to programs where it is useful (#41786) 2026-04-23 21:13:32 +02:00
Daan De Meyer 4985c70162 qmp-client: add synchronous qmp_client_call()
Add a synchronous counterpart to qmp_client_invoke() that pumps the
client's own process()/wait() loop until the reply for the issued
command id arrives, mirroring sd_varlink_call()'s contract: *ret_result
and *ret_error_desc are borrowed pointers into c->current, valid until
the next qmp_client_call(), and a QMP error surfaces as -EIO when the
caller doesn't ask for the description.

Factor the command-build + slot-insert + enqueue sequence shared with
qmp_client_invoke() into qmp_client_send(). A NULL callback marks the
slot as synchronous: dispatch_reply still matches on id (so unknown
ids continue to be logged and discarded, preserving async-only
robustness), but skips the TAKE_PTR + callback invocation and leaves
c->current pinned for qmp_client_call() to read out.

Cover the three paths in test-qmp-client: successful reply, QMP error
with ret_error_desc, and QMP error returned as -EIO.
2026-04-23 21:10:20 +02:00
Yu Watanabe 7aa8eabc8e dhcp-protocol: introduce several constants, string table lookups, and so on (#41710) 2026-04-24 03:54:55 +09:00
Zbigniew Jędrzejewski-Szmek b476483639 various: use empty block not break after OPTION_GROUP
Use the same style everywhere.
2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek 5d806036f9 TODO: add one more entry
This is something that should be fixed for usability, but it's something
between a missing feature and a bug. Since nobody has complained about
this, it probably can wait.
2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek 6fdc0f96f7 measure: also measure forgotten .efifw section 2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek ed469ffc07 measure: convert to the new option and verb parsers
Previously, we had a nice third 'UKI PE Section' column with the section
names. This is now moved into the help strings, which means that the nice
alignment is lost. Previous behaviour could be restored by constructing
the table manually, but I'm not sure if this is worth the trouble.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek 69d1f600d0 measure: reorder verb functions to match --help 2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek aa7ebb1b62 repart: use parse_tristate_argument_with_auto in one more place 2026-04-23 19:29:47 +02:00
Zbigniew Jędrzejewski-Szmek 785c9301de Use the new verb+option macros in pcrlock (#41669)
There's a lot of code movement, but the actual changes are
straightforward. Previously, the program was not marked as public, so
the --help/--version interface wasn't tested.
2026-04-23 19:15:30 +02:00
Zbigniew Jędrzejewski-Szmek 82a95edc92 repart: convert to the new option parser
The metavars for a few options were changed to be shorter, so that the
automatic alignment works better. Overall, I think the new version is
as least as legible as the old one.

The synopsis for -S/-C/-P is fixed, they do not take an argument.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek 04ad6079bb sbsign: convert to the new option and verb parsers
The options --private-key, --private-key-source, --certificate,
--certificate-source are almost identical in sbsign, but are described
slightly differently. Add OPTION_COMMON_ macros that are parametrized
to keep the purpose of the --private-key and --certificate options
in the description.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek b7f2c23da9 test-libudev: convert to the new option parser
The program now has a proper --help output. (Not on purpose. It's just
easier to do same thing as everywhere else.)

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek 39c5bee7c1 network-generator: convert to the new option parser
--help is the same except for whitespace.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek 108f6045cc shutdown: convert to the new option parser
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek 663a831089 stdio-bridge: convert to the new option parser
Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Zbigniew Jędrzejewski-Szmek f658387505 test-chase-manual: convert to the new option parser
--help now has help strings. --no_autofs is renamed to --no-autofs.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 19:13:44 +02:00
Christian Brauner 9e865599f7 chase: add explicit root_fd parameter to chaseat() and drop CHASE_AT_RESOLVE_IN_ROOT (#41652)
Split the single directory fd that chaseat() used to take into two
separate
fds: a root_fd that sets the chroot boundary (symlinks may not escape
it,
absolute symlinks resolve relative to it), and a dir_fd that path
resolution
starts from. This makes the chroot semantics of chaseat() explicit at
every
call site instead of encoding them in the CHASE_AT_RESOLVE_IN_ROOT flag,
which is removed. It also decouples the starting directory from the root
boundary, so callers can descend from any inode inside the tree without
having to reopen the root separately.

XAT_FDROOT passed as root_fd means "no containment" (host root); as
dir_fd
it means "start at root_fd". For a smoother transition, AT_FDCWD is also
accepted as root_fd and treated as XAT_FDROOT. When root_fd points to a
directory that is actually the host root, it is normalized to XAT_FDROOT
up front so the existing shortcut path can kick in.

Absolute paths returned by chaseat() are now relative to root_fd, and
relative paths are relative to dir_fd. The result is absolute only when
there is no chroot boundary (root_fd is XAT_FDROOT), or when an absolute
symlink made resolution jump out of the dir_fd subtree; otherwise
callers
get a relative path they can feed straight back into an openat()-style
call against dir_fd. Specifically, when dir_fd == root_fd and we're not
operating on the host's root directory, we return a relative path even
if
we received an absolute path or resolved an absolute symlink to allow
passing the path directly to openat() style functions. We do this to not
have to go modify every caller of chaseat() to make sure they deal
properly
with any absolute paths they might receive. Only when root_fd != dir_fd
do
we have to return an absolute path to indicate that the path is relative
to
root_fd and not dir_fd.

The shortcut that skips the per-component walk is reworked around a new
chase_xopenat() helper that funnels CHASE_NOFOLLOW, CHASE_MUST_BE_* and
CHASE_TRIGGER_AUTOFS through xopenat_full()'s O_NOFOLLOW, O_DIRECTORY,
XO_REGULAR, XO_SOCKET and XO_TRIGGER_AUTOMOUNT flags. As a result these
flags no longer force us off the shortcut and can be dropped from
CHASE_NO_SHORTCUT_MASK, and the old openat_opath_with_automount() helper
goes away. A CHASE_MUST_BE_ANY alias is introduced for shortcut callers
(stat/access paths) that don't go through xopenat_full() and still need
to bail on those flags locally.

All *_and_* helpers built on top of chaseat() (chase_and_openat,
chase_and_opendirat, chase_and_statat, chase_and_accessat,
chase_and_fopenat_unlocked, chase_and_unlinkat,
chase_and_open_parent_at)
gain the same root_fd parameter, and every call site in the tree is
ported to the new signature.
2026-04-23 19:10:21 +02:00
Christian Brauner 35a5e10e85 Merge branch 'main' into inode-ref 2026-04-23 19:10:15 +02:00
vlefebvre 14c7014d7f mkosi: user and group bin needed for a test
* Fix the test TEST-02-UNITTESTS for openSUSE environment.
2026-04-23 17:15:06 +01:00
Zbigniew Jędrzejewski-Szmek f5a99402d8 test: enable check-{help,version}-systemd-pcrlock
This is a normal user-facing program, so it should be tested
in the usual fashion.
2026-04-23 17:41:01 +02:00
Zbigniew Jędrzejewski-Szmek 3306104468 pcrlock: convert to the new option and verb parsers
The VERB definitions are done in order to retain the logical
presentation of verbs in lock+unlock pairs.

Previously --help output was too wide, it now fits in 80 columns.
Cosmetic changes in --help output only.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 17:41:01 +02:00
Zbigniew Jędrzejewski-Szmek ac2a0355fb pcrlock: reorder function definitions to match --help
The order was random, different in the source code, different in the
verb list, different in --help. Order source code by --help to make
the next patch manageable.
2026-04-23 17:41:00 +02:00
Lennart Poettering add93be960 man: clarify that /etc/verity.d only parses certificates with the .crt extension (#41790)
Exposed in the dracut testsuite while adding tests for sysexts:

```
[    2.972948] localhost (sd-merge)[510]: Validation of dm-verity signature failed via the kernel, trying userspace validation instead: Required key not available
[    2.972993] localhost (sd-merge)[510]: Skipping file '/etc/verity.d/dracut.pem', suffix is not '.crt'.
[    2.973045] localhost (sd-merge)[510]: No userspace dm-verity certificates found.
```


https://github.com/systemd/systemd/blob/658e5ac06f80ee2078b034f7cc483204d7f91c5e/src/shared/dissect-image.c#L3093
2026-04-23 17:28:16 +02:00
Lennart Poettering 6834fad2a7 iovec-util: introduce iovec_equal(), and add overflow check (#41700) 2026-04-23 17:13:33 +02:00
Antonio Alvarez Feijoo dfa5aa07b5 man: clarify that /etc/verity.d only parses certificates with the .crt extension
Exposed in the dracut testsuite while adding tests for sysexts:

```
[    2.972948] localhost (sd-merge)[510]: Validation of dm-verity signature failed via the kernel, trying userspace validation instead: Required key not available
[    2.972993] localhost (sd-merge)[510]: Skipping file '/etc/verity.d/dracut.pem', suffix is not '.crt'.
[    2.973045] localhost (sd-merge)[510]: No userspace dm-verity certificates found.
```
2026-04-23 15:39:29 +02:00
Antonio Alvarez Feijoo 341251b6e3 dissect-image: fix typo in log message 2026-04-23 15:39:14 +02:00
Bret Comnes 658e5ac06f Revert "resolve: refuse traffic from the local host only for queries"
This reverts commit 526f1594daec073269c3e70ee7914f6dd8740d5c.

This revert is necessary because the change breaks mDNS hostname stability
whenever a DNS-SD service calls UnregisterService. When a service
unregisters (e.g. on process restart), manager_refresh_rrs() clears and
re-adds all RRs in PROBING state, which sends a multicast announcement
(QR=1). The kernel reflects this back to resolved's own socket. Because
the local-address check was moved inside the query-only branch by the
reverted commit, the reply path in on_mdns_packet() is now unguarded.
The looped-back announcement matches the pending probe transaction and
completes it with DNS_TRANSACTION_SUCCESS. Since the zone item is still
in PROBING state (not ESTABLISHED), dns_zone_item_notify() sets
we_lost=true and calls dns_zone_item_conflict(), which invokes
manager_next_hostname() and renames the hostname (e.g. foo.local →
foo4.local). This happens reliably on every restart of any service using
RegisterService/UnregisterService (homebridge, avahi-compat wrappers,
etc.).

The top-level local-address check in on_mdns_packet() suppresses all
looped-back multicast traffic before the reply/query split. Restoring it
there is consistent with the overall design: dns_scope_check_conflicts()
already has its own manager_packet_from_local_address() guard and is
unaffected.

A more targeted long-term fix (e.g. guarding dns_transaction_process_reply()
for mDNS, or avoiding unnecessary re-probing of already-established records
in manager_refresh_rrs()) can be pursued separately.
2026-04-23 12:22:23 +02:00
Zbigniew Jędrzejewski-Szmek baa245ecd1 shared: drop redundant cryptsetup_enable_logging(NULL) calls (#41785)
These were only used to implicitly load libcryptsetup at startup.
dlopen_cryptsetup() now calls cryptsetup_enable_logging(NULL) itself,
and every code path that uses libcryptsetup calls dlopen_cryptsetup()
before doing so, so the upfront calls are no longer needed.
2026-04-23 12:18:45 +02:00
Antonio Alvarez Feijoo f9ac6aced9 repart: raise log level to LOG_ERR if dlopen_fdisk() fails
libfdisk is required by systemd-repart and it silently exits if dlopen fails
(unless the debug log level is set):

```
$ SYSTEMD_LOG_LEVEL=debug systemd-repart
Shared library 'libfdisk.so.1' is not available: libfdisk.so.1: cannot open shared object file: No such file or directory
$ echo $?
1
```

Follow-up for d49f3f287a
2026-04-23 12:16:58 +02:00
Luca Boccassi b54ef83414 repart: trim NUL bytes from verity sig split artifact
The verity signature partition content is a bare JSON object. Repart
pads it with zeros to fill the GPT partition. But when splitting out
the content as an individual file, the padding remains, so it's not
a valid text file.

jq started rejecting files with NUL bytes to fix a security issue:
https://github.com/jqlang/jq/commit/6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b

Trim the output when writing these files out.
2026-04-23 12:16:10 +02:00
Zbigniew Jędrzejewski-Szmek 1be5cbd6c1 dissect-image: fix path building for non-raw images (#41674)
If the passed in image path didn't end with .raw, we'd return an empty
string + suffix instead of the intended image + suffix path.

---

Also, fix two more nits that came up repeatedly in my searches.
2026-04-23 12:15:18 +02:00
Nandakumar Raghavan 1d78c2d327 gpt-auto-generator: do not fail on missing libcryptsetup when verity
is not used

add_veritysetup() is called unconditionally  from add_root_mount() and
add_usr_mount() whenever in_initrd() is true, to generate units that
only activate if verity devices appear. However, when compiled without
libcryptsetup, this function returned a hard error, causing the entire
generator to fail even when no verity protection is in use.

Change the #else fallback to log a debug message and return 0, matching
the pattern already used by add_root_cryptsetup().
2026-04-23 11:45:22 +02:00
Zbigniew Jędrzejewski-Szmek 8cb4ff428e shared/options: add a 'data' parameter to options
This mirrors a similar field in Verb. In some cases it convenient
to pass a fixed value to the parser.
2026-04-23 11:13:07 +02:00
Lennart Poettering f59b1f1a7d userdbctl: drop unused variable 2026-04-23 10:10:22 +01:00
Zbigniew Jędrzejewski-Szmek 9a3a861ff8 measure: fix oom check
Pointed out in review.
2026-04-23 11:09:11 +02:00
Zbigniew Jędrzejewski-Szmek d9506e7df7 meson: move fuzz-journald-util.c to fuzz-journal-audit
The .c file is shared between various fuzz-journal-* binaries. It
was added to 32bd43d768, but that is
somewhat ugly.

Let's add it to the alphabetially first fuzzer and share from there.

Follow-up for 32bd43d768 and
85b5acde86.
2026-04-23 10:13:25 +02:00
Zbigniew Jędrzejewski-Szmek 079361e8f0 meson: concatenate donors specified in 'objects'
Previously, we'd only honour the last donor.
2026-04-23 10:13:25 +02:00
Daan De Meyer 240b26503b shared: drop redundant dlopen_cryptsetup() calls from cryptsetup_* helpers
cryptsetup_set_minimal_pbkdf(), cryptsetup_get_token_as_json() and
cryptsetup_add_token_json() each take a struct crypt_device *cd, which
can only be obtained by first calling sym_crypt_init*() — and that
already requires dlopen_cryptsetup() to have succeeded. The internal
calls here were only implicitly re-loading a library the caller is
guaranteed to have already loaded.
2026-04-23 08:10:24 +00:00
Daan De Meyer 724e5b51e7 shared: drop redundant cryptsetup_enable_logging(NULL) calls
These were only used to implicitly load libcryptsetup at startup.
dlopen_cryptsetup() now calls cryptsetup_enable_logging(NULL) itself,
and every code path that uses libcryptsetup calls dlopen_cryptsetup()
before doing so, so the upfront calls are no longer needed.
2026-04-23 08:01:04 +00:00
Daan De Meyer 43dab5ea87 cryptsetup: load libcryptsetup via dlopen in setup binaries
Convert systemd-cryptsetup, systemd-cryptenroll, systemd-veritysetup
and systemd-integritysetup to go through the existing dlopen wrapper
for libcryptsetup instead of linking the library directly. Each binary
calls dlopen_cryptsetup() at the start of its run() and uses the sym_*
variants for every libcryptsetup entry point.

Extend cryptsetup-util.{h,c} to cover the libcryptsetup symbols that
these binaries use and that the wrapper was missing:
crypt_activate_by_token_pin, crypt_deactivate, crypt_init_data_device,
crypt_keyslot_status, crypt_set_keyring_to_link (conditional on
HAVE_CRYPT_SET_KEYRING_TO_LINK), crypt_status and
crypt_token_external_path.

With no direct callers of crypt_free() left, drop the non-sym
crypt_freep cleanup variant and rename sym_crypt_freep back to
crypt_freep via DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME, matching the
naming convention used by other dlopen wrappers (acl_freep,
xkb_context_unrefp, ...). Update the remaining users in src/shared,
src/repart, src/home and src/growfs to the new name.

The four affected meson targets switch from libcryptsetup to
libcryptsetup_cflags so they no longer record a DT_NEEDED entry for
libcryptsetup.so.12.
2026-04-23 06:42:24 +02:00
Daan De Meyer 4114bf7e70 repart: Fix xopenat_full() error handling 2026-04-23 06:41:26 +02:00
Daan De Meyer 909efb6f2e shared: load libgnutls and libmicrohttpd via dlopen
Convert the GnuTLS and libmicrohttpd usage in journal-remote to the
dlopen pattern used by other optional shared libraries. A new
src/shared/gnutls-util.{h,c} declares the GnuTLS entry points via
DLSYM_PROTOTYPE and resolves them in dlopen_gnutls(); microhttpd-util
is moved from src/journal-remote to src/shared and gains analogous
DLSYM_PROTOTYPEs plus dlopen_microhttpd(). Callers in journal-gatewayd,
journal-remote-main and microhttpd-util itself call the sym_* wrappers
and invoke dlopen_gnutls()/dlopen_microhttpd() at their entry points.

setup_gnutls_logger() no longer fails when libgnutls is missing at
runtime; it logs a notice and returns 0 so journal-gatewayd starts up
without TLS dependencies installed.

The meson files gain libgnutls_cflags and libmicrohttpd_cflags partial
dependencies that expose include paths and compile flags only. Every
systemd-journal-{gatewayd,remote,upload} target switches to the cflags
variant, dropping the direct libgnutls/libmicrohttpd link. The
gatewayd->remote object-sharing dance for microhttpd-util.o goes away
since the code now lives in libshared.

test-dlopen-so gains assertions for dlopen_gnutls and dlopen_microhttpd.
2026-04-23 06:41:05 +02:00
Clayton Craft 9149c75953 ukify: fix default path for hwids
The documentation and commit that added this seem to suggest this should
be under /usr/lib/systemd

fixes 117ec9db7e
2026-04-22 23:05:50 +01:00