Commit Graph
100 Commits
Author SHA1 Message Date
Yu Watanabe 83cc7f7ea8 in-addr-util: several cleanups (#43656) 2026-09-23 19:23:00 +09:00
Yu Watanabe 2727a7fad4 network: drop pending requests (#43741)
Fixes #39460.
2026-09-23 19:21:10 +09:00
Yu Watanabe de9ea9ea5d resolve: several cleanups for managing objects (#43629) 2026-09-23 15:54:02 +09:00
Yu Watanabe 830b60ae1f network: drop pending requests when a DHCP lease is lost or a client is stopped
When a DHCP lease is lost or a client is stopped, there may exist
requests not processed yet. We need to cancel them, otherwise an
address or route requested by the lost lease may be configured later.
2026-09-23 14:35:47 +09:00
Yu Watanabe 8698ce03d2 firewall-util: drop unnecessary restriction for the source address
Then, set assertions for the source address, as we already set non-NULL.
2026-09-23 13:53:23 +09:00
Yu Watanabe 5594d06b56 firewall-util: unify nft_message_append_setelem_iprange() and _ip6range() 2026-09-23 13:53:23 +09:00
Yu Watanabe 4ad65ce2f3 in-addr-util: drop unused in_addr_prefix_nth() 2026-09-23 13:53:23 +09:00
Yu Watanabe be21269a68 in-addr-util: reimplement in_addr_prefix_range()
Currently, in_addr_prefix_range() is the only user of in_addr_prefix_nth(),
and it is too generic and complicated.
Previously, in_addr_prefix_range() calls in_addr_prefix_nth() with 0 and 1.
The function in_addr_prefix_nth(0) is equivalent to in_addr_mask(), and
in_addr_prefix_nth(1) is equivalent to just increment the masked value
with 1.
So, let's reimplement the code without using in_addr_prefix_nth().
2026-09-23 13:53:23 +09:00
Yu Watanabe b4d5d083fd in-addr-util: drop unused in_addr_prefix_next() 2026-09-23 13:53:23 +09:00
Yu Watanabe 8dea243077 journalctl: make the read path 1.7x to 2.5x faster (#43663)
Three independent fixes to code on `journalctl`'s per-entry read and
output path. Each of them removes work that was never needed, rather
than trading away anything. There is no behaviour change: the output is
byte for byte identical for every format except `-o json`, where only
the order of the keys within each object can shift, which is already
nondeterministic between two runs of the unpatched binary (see the
correctness section below). Nothing about the formats, tunables or
public API changes.

Measured on a 730 MB journal spread over 100 files (roughly 2M entries):

| command | before | after | |
|---|---:|---:|---:|
| `journalctl -o cat` | 1.93s | 0.77s | **2.51x** |
| `journalctl --grep=<no match>` | 1.97s | 0.82s | **2.40x** |
| `journalctl -o export` | 4.06s | 1.73s | **2.35x** |
| `journalctl -n 100000 -o short` | 0.86s | 0.43s | **2.00x** |
| `journalctl -o json -n 200000` | 5.85s | 3.50s | 1.67x |
| `journalctl -o short` (the default) | 3.32s | 1.96s | **1.69x** |
| `journalctl -o verbose` | 5.99s | 3.61s | 1.66x |

### 1. `utf8_is_printable_newline()` decoded every character twice

`utf8_encoded_valid_unichar()` decodes the character internally in order
to validate it, and then throws the codepoint away. The caller
immediately called `utf8_encoded_to_unichar()` again to get the very
same codepoint back. So for every byte of every field printed, the UTF-8
decoder ran twice, only to answer whether the byte was a control
character.

This is fixed where it originates rather than at the call site:
`utf8_encoded_valid_unichar_full()` optionally returns the character it
had to decode anyway, so a caller that wants both the validity and the
value decodes once. On top of that, eight bytes are tested at once for
plain printable ASCII, which is what almost all journal content is. A
word that does not qualify falls through to the per character path
unchanged, so tabs, newlines and multibyte sequences behave exactly as
before.

On its own, against unmodified main: `-o export` 4.02s to 2.89s.

### 2. sd-journal read the clock once per journal file, per entry

`sd_journal_next()` sweeps every open journal file to find the next
entry, and `next_beyond_location()` rate limits its tail timestamp
refresh per file. Since `ratelimit_below()` reads the clock itself, a
journal spread over a hundred files meant a hundred `clock_gettime()`
calls for every single entry iterated, nearly all of them only to
conclude that the one second interval had not elapsed yet.

This was the single largest cost in `journalctl`. In a profile of `-o
export` it was over a fifth of the entire run, spent deciding not to do
the thing it was guarding.

Add `ratelimit_below_at()`, which takes the timestamp from the caller,
and read the clock once per sweep instead. `ratelimit_below()` keeps its
behaviour and becomes a wrapper.

The timestamp is now sampled once per sweep rather than once per file.
The interval being rate limited is one second and a sweep takes
microseconds, so this makes no practical difference.

On its own: `-o export` 4.02s to 2.93s, and `-o short` 3.30s to 2.14s.
This is the largest single contributor for the default output mode.

### 3. The JSON output built a fresh, unsized hashmap for every entry

`journal_entry_to_json()` creates an empty hashmap per entry and fills
it with that entry's fields, of which there are typically around twenty.
Because it starts empty it has to grow several times per entry, and
every growth rehashes everything inserted so far. `-o json` spent about
a quarter of its time in siphash, a third of that under
`resize_buckets()`.

Reserving room up front is a one line change.

On its own: `-o json -n 200000` 5.71s to 4.64s.
2026-09-23 13:52:44 +09:00
Yu Watanabe 1947733d74 nftables: allow to remove nftables table, rule, set, and so on (#43673)
This adds 'add' boolean parameter to sd_nfnl_nft_message_new_table() and
friends, so that we can remove nftables table and so on. In
test-firewall-util, before and after running test cases, remove the
garbage nftables test table.
2026-09-23 13:50:04 +09:00
Yu Watanabe c5bf6bac23 network: disable IPv4ACD when the address request is cancelled
If an address with IPv4ACD is requested, then sd_ipv4acd instance for
the address is configured. If the request is cancelled, we should
also disable the IPv4ACD instance.

Note, if the address is already configured, the IPv4ACD instance for the
address will be removed when the address is removed. See address_drop().
2026-09-23 13:39:40 +09:00
Yu Watanabe 4be31a9c35 network: add a configuration-source filter to link_drop_requests()
Preparation for later changes.
2026-09-23 13:39:40 +09:00
Yu Watanabe f30c9ea09c tar-util: several cleanups for ACL tag handling (#43684)
Prompted by 6df59b0753.
2026-09-23 12:52:20 +09:00
Yu Watanabe 724d18a22a analyze: introduce cpu-features command
This may be useful when configuring the ConditionCPUFeature= setting.
2026-09-23 12:51:26 +09:00
Yu Watanabe a4e4ced188 resolve: use custom hash_ops for managing Link objects 2026-09-23 11:38:15 +09:00
Yu Watanabe 7a19ecb825 resolve: several trivial cleanups for dnssd
- make several functions static,
- add serveral missing assertions,
- several coding style cleanups.
2026-09-23 11:38:15 +09:00
Yu Watanabe e677674522 resolve: use custom hash_ops for Manager.dnssd_registered_services 2026-09-23 11:38:15 +09:00
Yu Watanabe 3959ccbd32 resolve: drop unused argument t from mdns_service_update() 2026-09-23 11:38:15 +09:00
Yu Watanabe 923146d951 resolve: make several functions static 2026-09-23 11:38:15 +09:00
Yu Watanabe 02f65ebead resolve: stop timer event source and detach from browser when a dnssd service is removed
Otherwise, if the timer event source is enabled, a new query may be
invoked by the already removed service.

This also renames dns_remove_service() to dnssd_discovered_service_detach(),
and drops unused DnssdDiscoveredService.query.
2026-09-23 11:38:14 +09:00
Yu Watanabe 219abd95ae resolve: detach DnsServiceBrowser object from Manager when freed or disconnected
When a DnsServiceBrowser object is detached from the manager,
all queries, event sources, and then the reference to Manager should be
dropped. Otherwise, spurious query may be triggered for already
disconnected varlink.
2026-09-23 11:38:14 +09:00
Yu Watanabe 137ce9b975 resolved: split oversized mDNS announcements across MTU-sized packets (#43667)
Split out of https://github.com/systemd/systemd/pull/42983

## Problem
`dns_scope_announce()` put the entire zone into a single reply packet —
for DNS-SD that is every PTR/SRV/TXT record of every published service.
With a few hundred services that grows far past the interface MTU, and
past what RFC 6762 section 17 allows: a Multicast DNS packet larger than
the MTU is sent using fragments, and such a packet "MUST NOT contain
more than one resource record".

## Fix
Pack an announcement into as many MTU-sized packets as needed. A record
that does not fit the MTU on its own is emitted alone in an oversized
packet relying on IP fragmentation — the case section 17 explicitly
allows — bounded by its hard 9000-byte ceiling including headers, which
also caps jumbo-frame links.

Without a usable interface MTU (no link on the scope, or `IFLA_MTU` not
read yet) packets are cut to the largest datagram a host of the family
must accept unfragmented — RFC 791's 576 bytes for IPv4, RFC 8200
section 5's 1280-byte minimum link MTU for IPv6 — rather than to that
ceiling, so an announcement is never fragmented merely because the MTU
was not known yet, and the lone-oversized-record path stays reachable.

A record that cannot be encoded at any size (an rdata past 64KiB, a
character string past 255 bytes) is skipped like one too large for the
ceiling rather than failing the whole announcement:
`dns_packet_append_rr()` rolls the packet back on every failure, so its
neighbours are unaffected either way.

The packing lives in `resolved-mdns.c` as
`mdns_announcement_packetize()`, taking an answer and the two size
bounds and returning finalized packets, so it is testable without a
scope, a link or a socket. Emission is best effort per packet — a failed
send no longer withholds the rest — and each pass logs the packet and
record counts it actually put on the wire.
2026-09-23 11:36:09 +09:00
Yu Watanabe 6f58da1791 test-firewall-util: clear test tables in intro() and outro()
Otherwise, the test may fail when there is a garbage in the nftables.
2026-09-23 09:15:58 +09:00
Yu Watanabe 0ba6d54ef7 firewall-util: introduce fw_nftables_del_table() 2026-09-23 09:15:58 +09:00
Yu Watanabe 534a25c885 sd-netlink: add boolean 'add' parameter to sd_nfnl_nft_message_new_table() and friends
Previously, only sd_nfnl_nft_message_new_setelems() takes the 'add'
flag. Let's all functions take the boolean parameter for consistency.
2026-09-23 09:15:58 +09:00
Yu Watanabe d47f1599b8 sd-netlink: add missing assertions 2026-09-23 09:15:58 +09:00
Yu Watanabe 28e7ae95af tar-util: do not fail by adding an unknown acl tag
archive_entry_acl_add_entry() will fail when an unknown tag is set.
2026-09-23 09:11:54 +09:00
Yu Watanabe fa7d15b331 tar-util: simplify condition
No functional change, just refactoring.
2026-09-23 09:11:54 +09:00
Yu Watanabe fc77a3c1a6 tar-util: drop boolean 'skip' flag
No functional change, just refactoring.
2026-09-23 09:11:54 +09:00
Yu Watanabe f19861d9ac tar-util: use the same table for converting acl tag
Note, ACL_UNDEFINED_TAG == _ARCHIVE_ENTRY_ACL_UNDEFINED, hence this
does not change any behavior.
2026-09-23 09:11:54 +09:00
Yu Watanabe 35e0a8be96 fstab-generator: support for x-systemd.onfailure (#42440)
1. test-fstab-generator: fix inverted /mnt symlink guard

   The test-18-options.fstab.input scenario was guarded by a check
   that was always true on a normal system, so it was silently
   skipped and its fixtures had drifted out of sync with actual
   generator output. This commit fixes the guard and repairs the
   stale fixtures it exposed.

2. fstab-generator: support for x-systemd.onfailure

   Add support for the x-systemd.onfailure= fstab option in
   systemd-fstab-generator. This allows configuring OnFailure=
   dependencies for generated mount units directly through /etc/fstab.

   For example:
/dev/sda1 /data ext4 defaults,x-systemd.onfailure=emergency.target 0 2

   results in the generated mount unit containing:
   [Unit]
   OnFailure=emergency.target

   This makes it possible to attach recovery targets or services to
   mount failures directly from fstab configuration.

   Add documentation and generator tests.
2026-09-23 09:08:24 +09:00
Yu Watanabe 21561b5838 util: add ansi-seq-parser helper (#43661)
This is split out of #43058, but makes sense on its own: and makes
strip_tab_ansi() a lore more complete and correct.

ptybroker is going to use for the ansi sequence parser for other
purposes too, but making strip_tab_ansi() work better is enough of a
reason to have this I think.
2026-09-23 08:58:16 +09:00
Yu Watanabe 8e910fcaf1 dissect: optionally allow attaching images that do not qualify as DDIs with --attach (#43583)
It's nice to use --attach since it validates our images. So far, it
strictly insisted on checking that the image was a DDI however, which
limits its use for certain usecases.

Add "--relax" to address this limitation.

Fixes: #43605
2026-09-23 08:54:29 +09:00
Yu Watanabe e3ffb98da2 core: open more fields up to StartTransientUnit via Varlink (#43516)
This is split out of #43058 but makes a ton of sense on its own.
2026-09-23 08:50:36 +09:00
Yu Watanabe 0eb31f9fc7 Add more debugging to pam_systemd (#43763)
Figuring out what goes wrong when something doesn't work in the PAM
stack can be quite difficult. Add detailed debug messages to help.
2026-09-23 08:41:37 +09:00
Yu Watanabe 2f08761be4 utf8,format-table: make the console width helpers agree with the UTF-8 validators (#43653)
systemd has two UTF-8 decoders, and the console width path uses the
permissive one.

`utf8_encoded_to_unichar()` performs no overlong check, no
`unichar_is_valid()` check, and still accepts the obsolete five and six
byte forms. Those checks live in the wrapper
`utf8_encoded_valid_unichar()`, which is what `utf8_is_valid()` and
`ellipsize_mem()` use. `utf8_char_console_width()` called the bare
decoder directly.

Checking both against `utf8_is_valid_n()` over all 4,244,897,280 NUL
free byte strings of length one to four, which is the entire UTF-8
encoding space:

| decoder | disagreements with `utf8_is_valid_n()` |
| --- | --- |
| `utf8_encoded_valid_unichar()` | 0 |
| `utf8_encoded_to_unichar()` | 8,835,838, always more permissive |

So `utf8_console_width()` returned a finite width for strings
`utf8_is_valid()` rejects. `format-table.c` measures a cell with
`utf8_console_width()` and, when it does not fit, hands it to
`ellipsize()`, which validates strictly and returns NULL. That is
reported as `-ENOMEM`:

```
lead surrogate    valid_utf8=0  utf8_console_width=25  ellipsize=NULL
                    -> table_format FAILS: Cannot allocate memory
```

A surrogate, overlong, noncharacter or five byte sequence in any cell
failed the whole table with a bogus out of memory error, and only once
that column was narrow enough to need truncation, so whether it happened
depended on the width of the user's terminal. At other widths the
invalid sequence was printed to the terminal instead. Invalid cells are
now refused consistently with `-EINVAL`, which is what the sequences
`utf8_encoded_to_unichar()` already rejected always produced.

The second commit fixes a related disagreement. `ellipsize_mem()` and
`align_string_mem()` open coded character width as `unichar_iswide(c) ?
2 : 1`, while `unichar_console_width()` counts a tab as eight cells.
`format-table.c` uses both: it finds a field too wide with
`utf8_console_width()`, then asks `ellipsize()` to fit that many
columns, and `ellipsize()` thought a tab was one cell, so the result
still overflowed the column that the measurement had just asked it to
fit. A table pinned to `table_set_width(20)` emitted lines of 25, 44 and
39 columns. This uses `unichar_console_width()`, which was split out for
exactly this purpose in 5c0d4b5061.

Both commits add tests that fail before the change and pass after. The
full unit suite is otherwise unaffected.
2026-09-23 08:39:10 +09:00
Yu Watanabe 6a131b32e0 include: fix limits.h override
This is especially necessary since GCC 16.x.

=====
$ gcc --version
gcc (GCC) 16.2.1 20260819 (Red Hat 16.2.1-2)
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=====

Without this change, /usr/include/limits.h is not included, hence POSIX
constants are not defined:
=====
$ echo '#include <limits.h>' | gcc -E -H -isystem ~/git/systemd/src/include/musl - 2>&1 >/dev/null | grep '^\..*limit'
. /home/watanabe/git/systemd/src/include/musl/limits.h
.. /usr/lib/gcc/x86_64-redhat-linux/16/include/limits.h
... /usr/lib/gcc/x86_64-redhat-linux/16/include/syslimits.h
=====

With this change, /usr/include/limits.h is included, thus POSIX
constants are defined:
=====
$ echo '#include <limits.h>' | gcc -E -H -isystem ~/git/systemd/src/include/musl - 2>&1 >/dev/null | grep '^\..*limit'
. /home/watanabe/git/systemd/src/include/musl/limits.h
.. /usr/lib/gcc/x86_64-redhat-linux/16/include/limits.h
... /usr/include/limits.h
...... /usr/include/linux/limits.h
.. /usr/lib/gcc/x86_64-redhat-linux/16/include/limits.h
=====

Replaces #43824.
2026-09-22 18:14:12 +09:00
Yu Watanabe e362a4efcb namespace,condition: drop invalid _const_ attributes
The _const_ attribute can be only used for functions.

Fixes the following warnings on Fedora rawhide:
```
../src/core/namespace.h:260:75: warning: '__const__' attribute only applies to functions [-Wignored-attributes]
  260 | char* bpf_delegate_to_string(uint64_t u, const char * (*parser)(uint64_t) _const_);
      |                                                                           ^
../src/basic/../fundamental/macro.h:80:32: note: expanded from macro '_const_'
   80 | #define _const_ __attribute__((__const__))
      |                                ^
In file included from ../src/core/unit.c:24:
../src/shared/condition.h:87:63: warning: '__const__' attribute only applies to functions [-Wignored-attributes]
   87 | typedef const char* (*condition_to_string_t)(ConditionType t) _const_;
      |                                                               ^
../src/basic/../fundamental/macro.h:80:32: note: expanded from macro '_const_'
   80 | #define _const_ __attribute__((__const__))
      |                                ^
```
2026-09-22 02:46:35 +09:00
Yu Watanabe a6653a56c9 test-network: do not try to set too small quanta for ets
Since kernel v7.3 the kernel clamp quanta:
https://github.com/torvalds/linux/commit/1c38487f46b243bfeefec0c0c86023a3904f2214

So, too small values are now calmped to 256.
Let's change the values used in the test so that they are not clamped.
2026-09-21 13:31:06 +02:00
Yu Watanabe b36cf41a89 README.md: fix invalid </br> tags in badge list 2026-09-17 11:49:45 +09:00
Yu Watanabe 24de80f596 docs: fix typos and grammar in NEWS, README and TODO 2026-09-17 11:49:45 +09:00
Yu Watanabe 496712eddc docs: fix typos and grammar in various documents 2026-09-17 11:49:45 +09:00
Yu Watanabe 194c72b37f man: fix parameter controlling activatable names query for sd_bus_list_names()
The second conditional checked "acquired", but the ListActivatableNames
call is governed by the "activatable" argument.
2026-09-17 11:49:45 +09:00
Yu Watanabe 83c4191e25 man: fix inverted -ENODATA description for sd_bus_message_get_reply_cookie()
-ENODATA is returned when the message carries no (reply) cookie, but the
text stated the message "carries a reply cookie field". Say it does not
carry one.
2026-09-17 11:49:45 +09:00
Yu Watanabe 8787df83fe man: several fixlets for documentation of sd_bus_message_read_array()
- It does not accept NUL for type.
- ret_size is zero and ret_ptr is non-NULL when it returns positive.
- Fixed argument names: ptr -> ret_ptr, size -> ret_size.
2026-09-17 11:49:45 +09:00
Yu Watanabe 15bd45d113 man: fix typos and grammar in various man pages 2026-09-17 02:25:12 +09:00
Yu Watanabe 6a68191199 compress: avoid shifting null pointer
Otherwise, UBSAN complains when src is NULL even though the shift is zero:

../src/basic/compress.c:2074:29: runtime error: applying zero offset to null pointer
2026-09-10 00:11:29 +09:00
Yu Watanabe e0577192d0 tar-util: fix error code on failure (#43688) 2026-09-09 04:27:38 +09:00
Yu Watanabe 2170ce77f2 acl-util: make acl_set_perm() helper return negative errno
All callers expect it returns negative errno on failure.
2026-09-09 00:45:17 +09:00
Yu Watanabe f3a9444896 tar-util: fix error cause passed to logger 2026-09-09 00:45:17 +09:00
Yu Watanabe 2560925dd8 NEWS: fix typo 2026-09-07 20:43:18 +09:00
Yu Watanabe deef441b03 include: update kernel headers from v7.3-rc2
The only difference from the previous update is that now CONFIGFS_MAGIC
is listed in the magic.h, hence the override is not necessary anymore.
2026-09-07 19:36:29 +09:00
Yu Watanabe 5c7ca2d6a6 network: update route protocol string table
RTPROT_KEEPALIVED, RTPROT_OVN, and RTPROT_OPENR are added.
These are mostly used for logging, so documentation update is not
necessary.
2026-09-07 19:08:35 +09:00
Yu Watanabe 50a41d15b5 networkd-link: refactoring logger for IFF_ flags
No functional change.
2026-09-07 19:08:35 +09:00
Yu Watanabe 0b5d9bf140 wifi-util: update string tables
Note, NL80211_CMD_PROBE_CLIENT is renamed to NL80211_CMD_PROBE_PEER
in kernel v7.3:
https://github.com/torvalds/linux/commit/4ab9b637b94a3821acfcd6d6037dffe33669245a
2026-09-07 19:08:35 +09:00
Yu Watanabe 8577cfe2bc wifi-util: align table with = 2026-09-07 19:08:35 +09:00
Yu Watanabe 0b5c330d15 Several follow-ups for wildcard hostname (#43628) 2026-09-04 17:39:51 +09:00
Yu Watanabe 175b52e294 network-generator: use parse_path_argument() to avoid spurious paths 2026-09-04 11:26:11 +09:00
Yu Watanabe c21a49cd3d core/swap: don't resurrect swap units whose device link disappeared (#43443)
Fixes #43442.

A `.swap` unit can end up **active but unloadable, with no device**, and
stopping such a unit aborts PID 1.

### What it looks like

```
$ systemctl show 'dev-disk-byx2dpartlabel-primary.swap' -p LoadState,ActiveState,What
LoadState=not-found
ActiveState=active
What=                     # <-- no device

$ systemctl stop 'dev-disk-byx2dpartlabel-primary.swap'
systemd[1]: About to execute: /usr/sbin/swapoff        # <-- no argument
systemd[1]: Caught <ABRT>, from our own process.
systemd[1]: Freezing execution.
```

PID 1 stays alive but frozen, so the machine stops answering `systemctl`
and never reboots.

### How it happens
1. systemd creates one `.swap` unit per udev device link of every device
in `/proc/swaps`.
2. A device link gets repointed at another device while the swap stays
on. `/proc/swaps` doesn't change, so nothing re-examines the unit — it
stays active.
3. The next `daemon-reload` drops all units and rebuilds them.
Enumeration from `/proc/swaps` no longer produces this name, so only the
deserialization brings the unit back: by name, with no fragment on disk.
4. `swap_load()` only calls `swap_add_extras()` for units that loaded a
fragment or are backed by `/proc/swaps`, so this one gets neither a
`What=` nor a patched `ExecContext`.
5. `swap_coldplug()` restores its active state anyway.
6. Shutdown stops it. `unit_stop()` deliberately permits stopping units
whose load failed, so it reaches `exec_spawn()` and trips the
`PrivateVarTmp=` assertion in `exec_context_serialize()`.
2026-09-04 04:11:29 +09:00
Yu Watanabe d028295865 hostname-setup: use READ_FULL_FILE_VERIFY_REGULAR 2026-09-03 06:56:54 +09:00
Yu Watanabe 65a967fc46 test: several follow-ups for test-hostname-pick-word
'pos' must be >= 1, otherwise triggers assertion in
hostname_pick_word().
'c' should be >= 1, otherwise nothing tested.
2026-09-03 06:45:43 +09:00
Yu Watanabe 15f7905335 Tweak the hostname-worldlist code (#43599) 2026-09-03 06:29:25 +09:00
Yu Watanabe f559927982 test: fix ConditionCPUFeature= tests with architecture prefix
CPU architecture is determined by uname(), rather than the compile time
macros like __i386__, __x86_64__, __aarch64__.

Let's conditionalize with uname_architecture().

Follow-up for d518675741.
2026-09-03 06:16:05 +09:00
Yu Watanabe 736cb91535 resolved: actually unregister DNS-SD services when the D-Bus client vanishes (#43578)
Since the D-Bus DNS-SD API was introduced in c3036641f0ed (v236),
`RegisterService()` has created an `sd_bus_track` object to destroy the
registered service when the registering client disconnects from the bus.
However, the track object is a `_cleanup_(sd_bus_track_unrefp)` local in
`bus_method_register_service()` that is never stored anywhere, so it is
destroyed again as soon as the method handler returns. The vanish
handler (`dnssd_registered_service_on_bus_track()`) has thus been dead
code for the past ~8 years.

The observable effect: services registered via D-Bus silently persist
after the client disconnects — unowned, advertised until resolved exits,
and impossible to re-register since the identifier stays taken
(`DNSSD_SERVICE_EXISTS`). At the same time, the registration doesn't
survive a resolved restart, so the current behavior is neither reliably
ephemeral nor reliably persistent. Noticed while reviewing a project
that (unknowingly relying on this bug) registers a service with a
one-shot `gdbus call` and expects it to persist.

This PR:
1. splits the goodbye/zone-removal logic out of
`bus_dnssd_method_unregister()` into a helper — the vanish path needs
the full teardown, not just `dnssd_registered_service_free()`, which
would leave the service's RRs published in the per-link mDNS zones;
2. stores the track object in `DnssdRegisteredService`, making client
tracking work as originally intended;
3. documents the lifetime semantics in `org.freedesktop.resolve1(5)`
(matching the equivalent Avahi D-Bus API, whose entry groups are
likewise bound to the client connection) and points to `*.dnssd` files
for registrations independent of a client's lifetime;
4. adds a TEST-75 case covering the connection-bound lifetime.

Note this is a behavioral change for fire-and-forget clients (one-shot
`busctl`/`gdbus` invocations). Arguably those were never working
reliably (registrations silently vanished on any resolved restart, and
stale entries blocked re-registration), but if this is deemed too risky,
the alternative would be to drop the dead tracking code and codify the
persist-until-exit behavior instead — I'd argue tracking as originally
intended is the better contract.

Verification: code compiles; the new integration test is included.
2026-09-03 06:14:31 +09:00
Yu Watanabe 26f4d56015 compress: fix unbounded buffer growth on truncated streams, and fuzz the decompressors (#43589) 2026-09-02 19:59:51 +09:00
Yu Watanabe 636bd5a0e6 Revert "build(deps): bump meson from 1.11.2 to 1.12.0 in /.github/workflows"
This reverts commit a8ade912ce.
2026-09-02 00:09:25 +09:00
Yu Watanabe d0fcc5a9ec core: Don't racily stop Type=dbus services when the bus broker restarts (#42455) 2026-09-01 09:24:48 +09:00
Yu WatanabeandSiteshwar Vashisht 9064524e44 ndisc: fix a memory leak in ndisc_option_parse_encrypted_dns()
Newly allocated new_res variable was left unreferenced if memory
allocation failed in ndisc_option_add_encrypted_dns_internal().

Co-authored-by: Siteshwar Vashisht <svashisht@redhat.com>
2026-09-01 01:00:15 +09:00
Yu Watanabe dee2ea17c7 Update Linux kernel headers from v7.3-rc1 (#43573) 2026-09-01 00:59:36 +09:00
Yu Watanabe 69c8578c17 test: use linux/magic.h from our tree
We copy linux/magic.h from the kernel source tree and use it when
building systemd. Let's also make the kernel-filesystem-magics test
use the copy in our tree rather than the one installed on the system.

To achieve that now the 'check' command takes both 'cpp' and
'system_include_args' from meson.
2026-08-31 21:17:30 +09:00
Yu Watanabe 8220fcf4fe filesystem: correctly recognize failfs
The kernel v7.3-rc1 introduces failfs:
https://github.com/torvalds/linux/commit/fa0d6d945e5ce96cff14b114eec7527f13d7f23a
2026-08-31 19:43:10 +09:00
Yu Watanabe 6ce2db8dc2 include: update Linux kernel headers from v7.3-rc1 2026-08-31 19:43:10 +09:00
Yu Watanabe e7e91b9bc1 man: also document -V option for udevd and run0
The option -V has been documented in their help message, but not in the
corresponding man pages.
2026-08-29 07:40:43 +09:00
Yu Watanabe 69a54c37ac options: introduce OPTION_COMMON_VERSION_WITH_V and version_only()
The man page udevadm(8) have explicitly documented that the option -V is
a short form of --version. Let's not hide the short form in the help
message.

This introduces OPTION_COMMON_VERSION_WITH_V then use it in udevadm,
udevd, and run0.

Alos, this moves print_version() to build.c, and renames it to
version_only(). Now the function is also used in udevd amd test-libudev.

With this change, the -V option is hidden only in dmi_memory_id and
scsi_id. So, this removes the OPTION_COMMON_VERSION_WITH_HIDDEN_V macro
and explicitly list the hidden option in their code.
2026-08-29 07:40:35 +09:00
Yu Watanabe 39cf979007 Final batch of conversions to COMMAND and additions of --introspect-cli (#43558) 2026-08-29 04:26:12 +09:00
Yu Watanabe a2de89f622 libc: call epoll_pwait2 syscall directly instead of resolving glibc symbols
As mentioned in a05fe6684a, glibc provides two
wrappers for epoll_pwait2() on 32-bit architectures, and sys/epoll.h,
together with features-time64.h, selects the appropriate one.

To avoid depending on symbols introduced in newer glibc releases, that
commit relied on the glibc internal macro __USE_TIME_BITS64 to determine
which wrapper to use. However, that is incorrect on some architectures.
See:
https://sourceware.org/git/?p=glibc.git;a=commit;h=a4ed0471d71739928a0d0fa3258b3ff3b158e9b9

The above glibc commit introduces a new internal macro,
__USE_TIME64_REDIRECTS, which correctly describes whether the time64
wrapper should be used. However, we cannot rely on it because it was
introduced in glibc 2.40, while our baseline remains glibc 2.34.

Moreover, even after raising the baseline, relying on glibc internal
implementation details is undesirable.

Instead, call the epoll_pwait2 syscall directly. This avoids any
dependency on glibc wrapper selection logic while preserving the original
goal of avoiding newer glibc symbols.

As a side effect, this also enables epoll_pwait2() on musl, which does not
currently provide a libc wrapper for it.

Currently, epoll_pwait2() is only used by sd-event, so this is also the
simplest solution.
2026-08-28 06:19:13 +09:00
Yu Watanabe 82fb7a0297 import: dlopen libacl only when libarchive support is enabled
Otherwise, test-dlopen-note.py fails when libarchive support is disabled
but libacl support is enabled.

Also, log the dlopen_libarchive() failure at LOG_ERR level, matching how
the other failures are already logged.

Fixes #43530.
2026-08-27 17:05:34 +02:00
Yu Watanabe 445c6ce8a2 compress: several fixlets for decompressor (#43506) 2026-08-27 07:58:38 +09:00
Yu Watanabe 46c8f2e9b4 coredump: support kernel coredump socket (#43330)
This adds kernel coredump socket support added in v6.17. See
https://lore.kernel.org/all/20250603-work-coredump-socket-protocol-v2-0-05a5f0c18ecc@kernel.org/
2026-08-27 07:55:47 +09:00
Yu Watanabe 49132b134d README: mention several kernel features about coredump 2026-08-27 05:55:08 +09:00
Yu Watanabe 29de356679 man: update documentation for systemd-coredump 2026-08-27 05:55:03 +09:00
Yu Watanabe d649c186be test: support the new coredump services 2026-08-27 05:54:17 +09:00
Yu Watanabe daef042536 journal: also allow to store coredump by systemd-coredumpd.service 2026-08-27 05:52:53 +09:00
Yu Watanabe 264ca8f827 coredump: support kernel coredump socket protocol
Since kernel v6.17, we can set a path to unix socket to core_pattern
(with request mode). See also:
https://lore.kernel.org/all/20250603-work-coredump-socket-protocol-v2-0-05a5f0c18ecc@kernel.org/

This introduces a tiny service that prepares and listens on a UNIX
socket to be passed to the kernel core pattern. When a process is
crashed, the kernel connects to the socket, and sends information
about the crashed process and passes coredump through the socket.
The service accepts the connection, and forks a worker process that
receives coredump from the kernel.
2026-08-27 05:52:49 +09:00
Yu Watanabe 0351920ac7 coredump: do not coredump in setting up logger
If log_parse_environment() or log_set_target_and_open() triggers
assertion or so, then we may enter endless loop. Let's disable coredump
earlier.
2026-08-27 05:50:14 +09:00
Yu Watanabe 3fd564e876 coredump: do not try to read si_code more than once
This also renames coredump_context_read_pidfd_info() to
coredump_context_read_code(), as it only reads COREDUMP_CODE.

This does not change anything effectively, as the function is called
only once. Preparation for later change.
2026-08-27 05:50:14 +09:00
Yu Watanabe d81e6b93d6 process-util: split out procfs_get_stat_flags() from pid_is_kernel_thread() 2026-08-27 05:50:14 +09:00
Yu Watanabe 059b41654f include: add missing definition of PF_DUMPCORE 2026-08-27 05:50:14 +09:00
Yu Watanabe d8c0fa3cb8 import: finalize decompressor
Otherwise, the result may be truncated, or trailing garbage may be
silently accepted.
2026-08-27 04:36:57 +09:00
Yu Watanabe dac2b39405 compress: strictly check if stream finished on decompress
Previously, even when the compressed data was truncated, or had
trailing garbage, the decompressor might not detect it.

To fix the issue, update the check if stream is finished.
With this change, now decompressor_push() must be called with
size == 0 to finalize the stream.
2026-08-27 04:36:57 +09:00
Yu Watanabe d9b6e8663c compress: check cursor position in should_sparse()
Otherwise, the result will be broken, as skipped area by lseek() is not
cleared.
2026-08-27 04:36:57 +09:00
Yu Watanabe f577c38a52 compress: inline error handling 2026-08-27 04:36:50 +09:00
Yu Watanabe fefe8f3132 compress: use consistent error code for failure in BZ2_bzDecompressInit() 2026-08-27 04:36:29 +09:00
Yu Watanabe b9dbbccd20 compress: fix indentation and add short comment 2026-08-27 04:35:03 +09:00
Yu Watanabe d365c4cd52 compress: fix error handling for lzma_lzma_preset()
Follow-up for 91d6f1ee53.
2026-08-27 04:34:34 +09:00
Yu Watanabe fb1160c588 test-compress: replace writing zeros with ftruncate() + lseek() 2026-08-27 04:34:34 +09:00
Yu Watanabe dd997b4fb8 test-compress: compare decompressed data with source 2026-08-27 04:34:34 +09:00
Yu Watanabe 64b98140fa coredumpctl: several cleanups (#43481)
This splits coredumpctl.c into small pieces, and fixes several minor
issues such that memleak, unremoved temporary files, and missing
uncompressed core file handling. This also makes `coredumpctl
dump/debug` command accept --json= option that was previously silently
ignored.
2026-08-27 00:28:18 +09:00
Yu Watanabe 9fab87df93 udev,network: skip reloading if already in stopping state (#43504)
Prompted by #43482.
2026-08-27 00:26:58 +09:00