Commit Graph
37 Commits
Author SHA1 Message Date
Anton Tiurin 7bd9f0f805 dhcp-server: reject pool offsets beyond the subnet (#43389)
`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`.
2026-08-16 03:35:45 +09:00
noxiouz bb233dcb4b coredump: add JSON output support to coredumpctl info
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>
2026-05-14 15:53:13 +01:00
noxiouz 9bd72b612b compress: write sparse files when decompressing to regular files
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>
2026-04-08 23:44:23 +01:00
noxiouz 69b6e950e2 networkd-wwan: drop unreachable unknown-bearer fallback path
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>
2026-04-08 17:28:19 +02:00
noxiouz 836de2900b coredumpctl: use NULL outputs for COREDUMP existence checks
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>
2026-04-08 16:33:20 +02:00
noxiouz a5c811591f sd-journal: skip full decompression when caller only checks field existence
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>
2026-04-08 16:33:20 +02:00
noxiouz 329233dcbf sd-journal: make sd_journal_get_data() output params optional
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>
2026-04-08 16:33:20 +02:00
noxiouz b5a1ecb8fc networkd-wwan: handle link_get_by_name() errors in modem_simple_connect()
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>
2026-04-08 13:59:32 +02:00
noxiouz 34649c6f55 networkd: keep static lease section valid on MACAddress= reset
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>
2026-04-08 13:57:39 +02:00
noxiouz 874fbb870c coredumpctl: use loop_write() for dumping inline journal coredumps
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>
2026-04-07 17:56:36 +01:00
noxiouz 6e76281b2f journald-native: fix field-count limit off-by-one
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>
2026-04-07 11:22:45 +02:00
noxiouzandClaude Opus 4.6 7d5ec30862 network: add unmanaged interface checks to Link.Renew and Link.ForceRenew Varlink methods
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>
2026-03-19 11:50:45 +00:00
noxiouz 1416d3b69c networkctl: drop unused functions
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouzandYu Watanabe 689e45a6cd networkctl: use io.systemd.Network.Link.Describe() Varlink method
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>
2026-03-18 22:55:52 +00:00
noxiouz e90ea94392 network: add io.systemd.Network.Link.Describe() Varlink method
The handler returns the JSON produced by link_build_json().

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouzandYu Watanabe 54e8ea6552 networkctl: use io.systemd.service.Reload() method
Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 6627dfe425 network: implement io.systemd.service.Reload() in networkd
Bind networkd's reload handler to the generic io.systemd.service.Reload
method.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz 506890fa0d network: add io.systemd.Network.Link.Reconfigure() Varlink method
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>
2026-03-18 22:55:52 +00:00
noxiouz 982a3fa59f network: add io.systemd.Network.Link.ForceRenew() Varlink method
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>
2026-03-18 22:55:52 +00:00
noxiouz 5e7287c2b5 network: add io.systemd.Network.Link.Renew() Varlink method
The handler calls dhcp4_renew() and logs a warning on failure.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 22:55:52 +00:00
noxiouz f8722d4033 network: extend link_reconfigure_full() and manager_reload() for Varlink
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>
2026-03-18 22:55:52 +00:00
noxiouz 872feaa006 network: add BitRates field to link_build_json() and the Varlink IDL
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>
2026-03-18 22:55:52 +00:00
noxiouz f9ebd7bb06 network: extract link_get_bit_rates() into networkd-speed-meter.c
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>
2026-03-18 22:55:52 +00:00
noxiouz 4c7af7d9d1 coredump: capture crashing thread ID and name
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>
2026-03-18 10:27:27 +00:00
noxiouz fbf533859f network: fix error aggregation in wwan_check_and_set_configuration()
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.
2026-03-03 08:59:48 +09:00
noxiouz 8d421c0870 network: fix LLDP field type in Interface Varlink IDL
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.
2026-03-03 00:04:50 +01:00
noxiouz 3d54a40dae login: add missing NoSessionPIDFD error to io.systemd.Login IDL
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
2026-03-02 10:08:57 +00:00
noxiouz 3eacf0d321 login: fix ReleaseSession.Id dispatch flag in io.systemd.Login Varlink handler
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
2026-03-02 10:06:39 +00:00
Anton Tiurin ce1361d7b3 resolved: use DNS_TYPE_DNSKEY for trust anchor support (#40850)
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
2026-03-02 13:44:26 +09:00
Anton Tiurin 2506a57bca resolve: add missing ServiceNotProvided error to Varlink IDL (#40858)
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.
2026-03-02 13:22:14 +09:00
noxiouz 1fc868ac6b core: fix typo in Unit.List sentinel error name 2026-03-02 13:19:33 +09:00
noxiouz 3d9191cd5c shared: fix sysext ImageType IDL missing mstack value, add enum IDL test
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.
2026-02-27 08:49:54 +01:00
noxiouz 37b8cd71cd shared: fix comment typos in Udev and AskPassword Varlink IDL 2026-02-27 08:49:21 +01:00
noxiouz 54796ea3b2 mountfsd: include imageName in MountImage Varlink reply 2026-02-27 08:48:48 +01:00
noxiouz c22a131e74 import: fix AlreadyInProgress Varlink error missing remote field
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.
2026-02-27 08:48:25 +01:00
noxiouz 56d44e8a02 hostname: fix OperatingSystemImageID/Version Varlink IDL
Both fields are populated from IMAGE_ID/IMAGE_VERSION in os-release,
which are plain strings.

Fix typo in include.
2026-02-27 04:09:15 +01:00
Anton Tiurin 9893859beb networkctl: change bitrate format from 'bps' to 'Bps' 2025-09-26 14:41:20 +09:00