`sd_dhcp_server_configure_pool()` calculated the maximum pool size
before checking whether `PoolOffset=` was inside the subnet.
Because the calculation used unsigned arithmetic, an offset beyond the
broadcast address could wrap around to a large value and pass validation.
For example, `PoolOffset=256` with a `/24` and `PoolSize=1` was accepted,
allowing the DHCP server to offer an address outside its configured subnet.
Reject offsets at or beyond the broadcast address before performing the
subtraction, and calculate the remaining pool size directly as
`broadcast_off - offset`.
Implement support for the --json= flag in the info subcommand
(issue #38844). Previously, coredumpctl info always produced
human-readable text output regardless of --json=.
Add a CoredumpFields struct that holds all journal fields extracted
for a coredump entry, along with coredump_fields_done() to release
member resources and coredump_fields_load() to populate the struct
from a journal entry. Both print_info() and the new print_info_json()
use this shared loader, eliminating the duplicate RETRIEVE loop.
print_info_json() builds a JSON object with the same fields shown by
print_info(). Missing fields are omitted via SD_JSON_BUILD_PAIR_CONDITION,
matching the tolerant behavior of print_info() rather than skipping the
entry entirely. Signal/Reason handling mirrors print_info(): normal
coredumps (MESSAGE_ID == SD_MESSAGE_COREDUMP_STR) emit a numeric Signal
field; non-normal entries (kernel oops, etc.) emit a Reason field with
the raw text from COREDUMP_SIGNAL.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Core dumps are often very sparse, containing large zero-filled regions
whose actual disk usage can be significantly reduced by preserving
holes. Previously, decompress_stream() always wrote dense output,
expanding all zero regions into allocated disk blocks.
Each decompression backend (xz, lz4, zstd) now auto-detects whether the
output fd is suitable for sparse writes via a shared should_sparse()
helper. The check requires both S_ISREG (regular file) and !O_APPEND,
since O_APPEND causes write() to ignore the file position set by
lseek(), which would collapse the holes and corrupt the output. For
pipes, sockets, and append-mode files, dense writes are preserved via
loop_write_full() with USEC_INFINITY timeout, matching the original
behavior. After sparse decompression, finalize_sparse() sets the final
file size to account for any trailing holes.
This is transparent to callers — all public signatures are unchanged.
coredumpctl benefits automatically:
- coredumpctl debug: temp file in /var/tmp is now sparse
- coredumpctl dump -o file: output file is now sparse
- coredumpctl dump > file: redirected stdout is now sparse
- coredumpctl dump | ...: pipe output unchanged (dense)
- coredumpctl dump >> file: append mode, falls back to dense
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
bearer_get_by_path() only succeeds when both modem and bearer are found.
On failure, trying bearer_new_and_initialize(modem, path) was
unreachable and relied on a modem value that is not returned on that
path.
Treat unknown bearers as no-op and rely on modem_map_bearers() for
association during initialization.
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
print_list() and print_info() used RETRIEVE() to strndup() the entire
COREDUMP field into a heap-allocated string, only to check whether it
exists. With sd_journal_set_data_threshold(j, 0) in print_info(),
this copies the full coredump binary (potentially hundreds of MB) to
heap just to print "Storage: journal".
Now that sd_journal_get_data() accepts NULL output pointers, use a
direct NULL/NULL existence check instead.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
When both ret_data and ret_size are NULL after decompress_startswith()
has confirmed the field matches, skip the decompress_blob() call.
This avoids decompressing potentially large payloads (e.g. inline
coredumps) just to discard the result.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Allow callers to pass NULL for ret_data and/or ret_size when they only
need to check whether a field exists. Initialize provided output
pointers to safe defaults and update the manual page accordingly.
Propagate the NULL-ness through to journal_file_data_payload() so that
downstream helpers can optimize for the existence-check case.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
modem_simple_connect() ignored the return value of link_get_by_name()
and then checked link for NULL. Since the helper only sets the output
pointer on success, that could read an indeterminate value.
Check and log the return code directly with log_debug_errno().
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
config_parse_dhcp_static_lease_hwaddr() uses a cleanup helper that marks
a lease section invalid unless ownership is taken.
Add TAKE_PTR(lease) on the empty-rvalue reset path so subsequent valid
MACAddress= assignments in the same section are not dropped.
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
Replace the bare write() call with loop_write(), which handles short
writes and EINTR retries. This also drops the now-unnecessary ssize_t
variable and the redundant r = log_error_errno(r, ...) self-assignment,
since loop_write() already stores its result in r.
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
Reject entries once the configured maximum field count is reached.
The previous check used n > ENTRY_FIELD_COUNT_MAX before appending a new field,
which let one extra field through in boundary cases. Switch the check to
n >= ENTRY_FIELD_COUNT_MAX so an entry at the limit is rejected before adding
another property.
Co-developed-by: Codex (GPT-5) <noreply@openai.com>
The D-Bus counterparts (bus_link_method_renew, bus_link_method_force_renew)
reject calls on unmanaged interfaces with BUS_ERROR_UNMANAGED_INTERFACE,
but the Varlink methods silently succeed. Add the same guard to both
Varlink methods, returning io.systemd.Network.Link.InterfaceUnmanaged,
and declare the error in the IDL.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This makes networkctl fetch bit-rate statistics and offered DHCP
leases via Link.Describe() method instead of D-Bus.
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
The handler calls link_reconfigure_full() with UNCONDITIONALLY|CLEANLY
flags and defers the Varlink reply until reconfiguration completes.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
The handler calls sd_dhcp_server_forcerenew() if the server is running
and logs a warning on failure.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Add an sd_varlink* parameter to both functions so Varlink callers can
receive a deferred reply once all async work completes, symmetrically
with the existing sd_bus_message* path.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Expose the speed meter transmit/receive rates as a BitRates struct in
the per-link JSON output and the io.systemd.Network Varlink IDL.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Move the bit-rate computation out of property_get_bit_rates() in
networkd-link-bus.c into a standalone link_get_bit_rates() helper in
networkd-speed-meter.c, which already owns the speed meter state.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Add %I (TID in initial PID namespace) to the core_pattern, so the
kernel passes the crashing thread's TID to systemd-coredump. Use it
to read the thread's comm name from /proc/<tid>/comm and log both as
new journal fields:
COREDUMP_TID= — TID of the crashing thread
COREDUMP_THREAD_NAME= — comm name of the crashing thread
These fields are also stored as xattrs on external coredump files
(user.coredump.tid, user.coredump.thread_name) and displayed by
coredumpctl info alongside the PID line.
For single-threaded processes the TID equals the PID and thread_name
equals comm; for multi-threaded programs with named worker threads
(pthread_setname_np / PR_SET_NAME) this identifies which thread
crashed without needing to open the coredump file itself.
The new fields are optional in the socket forwarding path, so older
systemd-coredump senders are handled gracefully.
Co-developed-by: Claude <claude@anthropic.com>
When removing marked routes, the condition `if (ret)` incorrectly
overwrites any previously accumulated error in `ret` with the latest
return value `r`, even if `r >= 0` (success). This means an earlier
real error can be silently cleared by a subsequent successful
route_remove() call.
The parallel address_remove() block just above uses the correct
`if (r < 0)` pattern. Apply the same fix to the route_remove() block.
sd_lldp_tx_describe() returns a single object (the LLDP TX configuration),
but the IDL declared LLDP as SD_VARLINK_ARRAY|SD_VARLINK_NULLABLE. This
caused server-side validation failures ("Field 'LLDP' should be an array,
but it is of type 'object'") whenever networkctl status was called on an
interface with LLDP TX active.
Also fix the field comment: the LLDP field represents the transmit
configuration, not received neighbors.
Follow-up for dd2934d44e.
The error is emitted by vl_method_create_session() when the session leader
process does not have a pidfd available, but was never declared in the IDL.
Fixes: 3180c4d461
The ReleaseSession method's Id field is declared as nullable (?string) in
the IDL, allowing callers to omit it so that the method releases the
caller's own session via session_is_self(NULL). The SD_JSON_MANDATORY flag
in the dispatch table contradicts this and makes omitting Id return -EINVAL
("Invalid argument", parameter "Id") instead.
Drop the flag so omitting Id is treated as passing NULL.
Fixes: 2baca6c22b
Fix typo: DNS_TYPE_DNSKEY should be used instead of DNS_TYPE_KEY.
- DNS_TYPE_KEY is deprecated
- Source code at resolved-dns-trust-anchor.c#L313 handles
DNS_TYPE_DNSKEY records, but not DNS_TYPE_KEY
So DNS_TYPE_KEY is not referenced anywhere
The error is emitted by `vl_method_resolve_service_complete()` when an
SRV record with a root domain hostname is found, indicating the service
is explicitly not offered on the queried domain (RFC 2782 Usage Rules),
but was not declared in the `io.systemd.Resolve` interface definition.
Follow-up for 3d8f2c1464.
Add the missing 'mstack' value to the ImageType enum in the
io.systemd.sysext Varlink IDL — image_type_table in discover-image.c
already defines IMAGE_MSTACK = "mstack" but it was absent from the IDL.
Export vl_type_ImageType so the test can reference it, and add
TEST_IDL_ENUM(ImageType, ...) to the enums_idl test to catch
similar regressions in the future.
The handler sends the remote URL as a parameter via sd_varlink_errorbo()
but the IDL declared the error with no fields, making the payload
undiscoverable via introspection.