Commit Graph
91606 Commits
Author SHA1 Message Date
Luca Boccassi bc17a73107 core: don't exit 0 when a failure action has nothing to propagate (#43647)
Fixes #43645.

`FailureAction=exit` propagates the exit status of the unit's main
process. When there is none, `emergency_action()` left `m->return_value`
at its initial 0, so the manager exited 0 for a unit that failed —
indistinguishable from an orderly shutdown to whoever supervises it.
2026-09-05 11:54:29 +01:00
Totoro f789245918 machine: preserve read-only clone mode for foreign UID images
machinectl clone --read-only ignored the requested read-only mode when
cloning a foreign-UID-owned directory because the unprivileged clone path
did not receive the read_only argument.

Pass the flag through and apply the immutable bit via the already-open
destination directory fd after copying. Keep this best-effort, matching
the ordinary directory clone fallback, so failure to set the attribute
does not turn a completed copy into a reported clone failure.

Add a regression test using foreign-0 rather than a fixed UID. Verify
the cloned image's ReadOnly property, copied contents and ownership, and
that the immutable directory rejects new entries. Run this subtest only
when file attributes and the existing rootless nspawn prerequisites are
available, leaving the other machined tests unchanged.
2026-09-05 08:34:55 +02:00
Totoro 0c8f57cae2 machine: propagate foreign image clone directory errors
unprivileged_clone() returns success when mountfsd_make_directory() fails.
Consequently, callers can report a successful clone even though the
destination directory was never created.

Return the original error instead of zero so the failed clone is
reported to the caller.

Add a regression test that places a regular file without an image suffix
at the destination path. Such a file is ignored by image discovery but
prevents directory creation. Check that cloning reports failure without
changing the file, then succeeds after the conflicting file is removed.
2026-09-05 08:32:02 +02:00
Totoro 7fa7ff87cd sysupdate: Permit mount namespaces in Varlink service
The Varlink service enumerates image targets and needs a private mount
namespace while dissecting images. Keep its sandbox in sync with
systemd-sysupdated.service.

Follow-up to 31616d00ef

Fixes #43604
2026-09-05 08:22:45 +02:00
Justin Cabral 726e17a933 hwdb: add MacBookAir9,1 T2 touchpad 2026-09-05 11:26:21 +09:00
Michael Renner 101b8633c2 journal: recover iteration over vacuumed files (#43649)
Vacuuming unlinks and deallocates archived journal files. A reader
may have already selected an entry from such a file, so final
validation can fail after candidate selection succeeded.

If the selected file is now unlinked, remove it and retry candidate
selection. Preserve errors from linked files, including the EIO
reported after SIGBUS recovery from a truncated mapping.
2026-09-05 11:17:59 +09:00
Chris Hasiński d57ad97128 hwdb: mark Apple T2 MacBook touchpads as internal 2026-09-04 21:27:45 +01:00
Yu Watanabe 0b5c330d15 Several follow-ups for wildcard hostname (#43628) 2026-09-04 17:39:51 +09:00
Totoro f4a7117af2 network: honor --root= for picked up credentials
network-generator writes generated command line configuration below
the alternate root passed with --root=, but network.* credentials
were copied to fixed host /run paths.

Build the credential target directories with arg_root before passing
them to pick_up_credentials(). This keeps normal boot behavior
unchanged while making credential output land in the requested root.
2026-09-04 14:22:25 +09:00
Armaan Sandhu 4a25049a9e resolved: don't disable the listening socket when a datagram is dropped
manager_recv() sizes its buffer with next_datagram_size_fd(), which peeks at
the datagram with MSG_PEEK|MSG_TRUNC. That peek makes the kernel verify the UDP
checksum - which is the whole point of using it over FIONREAD - and hence also
drop the datagram when the checksum is bad. The datagram that woke the event
source can thus be gone by the time we peek at it, and the peek returns EAGAIN.

manager_recv() returned that error, while the recvmsg_safe() below, which can
fail the same way, already treats it as "no packet". The callers on the mDNS,
LLMNR and stub listening sockets pass a negative return on to the event loop,
which disables the event source, so a single datagram with a bad checksum -
something anyone on the link can send - stops resolved from receiving on that
socket for good. on_dns_packet() completes the transaction with -EAGAIN instead
of retrying it.

So return 0 on a transient error here too, like the other users of the helper
on an event source do. Disconnect errors are left as they are: they show up
here from ICMP errors on the connected UDP socket, and on_dns_packet() handles
them.
2026-09-04 13:53:04 +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
Siteshwar Vashisht 504ebbe826 creds-util: add a check in decrypting credentials
... and avoid continuing decryption in case of failure.
2026-09-04 03:29:27 +09:00
Siteshwar Vashisht b4f2262be8 journal: fix cleaning up iovec entries
... when journald's messages exceed `kmsg_own_ratelimit`.
2026-09-04 03:29:00 +09:00
Ivan Kruglov 2b42e4f0c9 man: document what a failure action returns without an exit status 2026-09-03 10:18:29 -07:00
Ivan Kruglov 369bb5862b test: add a test for issue #43645 2026-09-03 10:18:29 -07:00
Ivan Kruglov 566436f1c6 core: don't exit 0 when a failure action has nothing to propagate
FailureAction=exit propagates the exit status of the unit's main process. When
there is none, emergency_action() left m->return_value at its initial 0, so the
manager exited 0 for a unit that failed. Whoever supervises it, e.g. a container
manager, then can't tell this apart from an orderly shutdown.

There is no status to propagate whenever the unit type has no notion of a main
process (only .service has), or the unit failed before any of its processes ran,
say because its cgroup couldn't be created. StartLimitAction= and
JobTimeoutAction= never have one at all.

Fixes: https://github.com/systemd/systemd/issues/43645
2026-09-03 10:09:32 -07:00
Ivan Kruglov d4b6e74655 core: use EXIT_EXCEPTION instead of a bare 255
No functional change.
2026-09-03 10:09:02 -07:00
Lennart Poettering 92c9f787a7 NEWS: various updates 2026-09-03 17:45:02 +02:00
Luca Boccassi 8cceaab8f5 ukify: generate initrd policy digests for offline signing
When --sign-initrd-pcrs is used with --policy-digest, generate the
extra enter-initrd policy with the "initrd" policy reference. This
matches the policy produced when ukify signs with a private key.

Fixes building UKIs with offline signing (e.g.: on OBS) and using
NVPCRs.

Follow-up for f0f3687700
2026-09-03 12:55:15 +02:00
nl6720 786fcb493f networkd: allow systemd-network user to control ModemManager
systemd-networkd needs authorization for
`org.freedesktop.ModemManager1.Device.Control` to allow establishing a
connection:

    systemd-networkd[1457]: ModemManager: starting simple connect on huawei E3276 interface wwp106s0u4i2
    systemd-networkd[1457]: Could not connect modem huawei E3276: Unauthorized: PolicyKit authorization failed: not authorized for 'org.freedesktop.ModemManager1.Device.Control'
2026-09-03 18:05:17 +09:00
Daan De Meyer 73aa9523d6 Ensure contributors engage with their AI written code
Let's add a canary so that we can distinguish AI written
code that was not looked at in any way or form by its author
easily in pull requests.
2026-09-03 09:37:52 +02: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
Armaan Sandhu 2451b1a9c4 resolve: fix use-after-free of the service browser in mDNS maintenance
mdns_maintenance_query_complete() takes a reference on
query->dnsservice_request and never drops it, so every successful mDNS
maintenance query leaks one reference to the discovered service.

The leak alone would be benign, but the service owns the one-shot event
source that drives its maintenance schedule, and it only borrows a plain
pointer to its service browser. Once the extra reference is outstanding,
dns_service_browser_free() -> dns_remove_service() only drops the list's
reference, so dns_service_free() never runs, the maintenance timer is
never disabled, and the service outlives the browser it points at. The
next time the timer fires, mdns_maintenance_query() dereferences the
freed DnsServiceBrowser to reach the manager's event loop and to issue
the query.

Reaching it only takes a browse subscription whose record lives long
enough for one maintenance query to be answered, followed by the
subscription going away.

Make the reference a _cleanup_ one, the way the sibling
mdns_browse_service_query_complete() below already handles the reference
it takes on the service browser.
2026-09-03 06:37:53 +09:00
Luca Boccassi a019396d2c tools: fix building manpages with lxml 6.1.3
manpages build fails on Arch with new lxml:

Traceback (most recent call last):
  File "/work/src/tools/make-directive-index.py", line 169, in make_page
    _extract_directives(directive_groups, formatting, page)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/work/src/tools/make-directive-index.py", line 18, in _extract_directives
    t = xml_parse(page)
  File "/work/src/tools/xml_helper.py", line 25, in xml_parse
    doc = tree.parse(page, _parser)
  File "src/lxml/etree.pyx", line 3717, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 2045, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 2071, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1962, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1231, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 647, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 765, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 689, in lxml.etree._raiseParseError
  File "../src/man/hostname.xml", line 5
lxml.etree.XMLSyntaxError: Entity 'entities' not defined, line 5, column 11

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/work/src/tools/make-directive-index.py", line 180, in <module>
    _xml = make_page(_template_path, _xml_files)
  File "/work/src/tools/make-directive-index.py", line 171, in make_page
    raise ValueError('failed to process ' + page) from e
ValueError: failed to process ../src/man/hostname.xml

Relying on XMLParser() defaults leaves the external parameter entity
used to load custom-entities.ent unresolved. Request entity resolution explicitly.

Follow-up for 1a13e31d27
2026-09-03 06:34:04 +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
Siteshwar Vashisht 00ca860b2c ndisc: fix an out of memory condition
... and skip the loop when building NDisc option fails.
2026-09-03 05:53:35 +09:00
Luca Boccassi a7ee2a5ea4 mkosi: update opensuse commit reference to 60fbc2d95581a933f9dcdfdb8d7e27d2a7d13e35
* 60fbc2d955 Update systemd to version 261.2 / rev 473 via SR 1368021
* c32d9727e6 Update systemd to version 261.1 / rev 472 via SR 1365923
* 74fd672013 Update systemd to version 260.3 / rev 471 via SR 1362701
* 769e1c4254 Update systemd to version 260.2 / rev 470 via SR 1361320
2026-09-03 05:48:24 +09:00
Franck Bui b5d3e4fa8c test-os-util: test os_release_support_ended() with a date > 2038
SUSE regularly builds packages into the future to track issues like the the
ones that might happen in 2038:
https://www.reddit.com/r/linux/comments/xjtf3q/in_the_year_2038/

Make sure that os_release_support_ended() doesn't fail in this case.

PS: on 32-bit systems time_t cannot represent dates past 2038, so use a safe
date there instead.
2026-09-02 16:52:28 +01: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
Stefan Agner 6decadbebf test: silence SC2329 for indirectly invoked cleanup() functions
shellcheck 0.10+ reports SC2329 ("This function is never invoked") for
the per-testcase cleanup() functions in TEST-75-RESOLVED.sh, which are
only invoked indirectly via trap. The existing SC2317 markers don't
cover it, and inserting a new testcase shuffles which definitions the
heuristic fires on, making pre-existing findings show up as new in
differential CI runs. Extend the markers to SC2317,SC2329, matching
what testcase_dot_strict_per_link_verify() in this file and other test
units already do.
2026-09-02 10:41:54 +02:00
Stefan Agner 908c38f300 test: add test for DNS-SD D-Bus registration lifetime
Verify that a DNS-SD service registered via the D-Bus RegisterService()
call is bound to the lifetime of the client's bus connection: since
busctl disconnects right after the call returns, the service must be
unregistered again shortly after. Wait for resolved's vanish handler
log message as proof that the client tracking triggered the
unregistration, check that a subsequent UnregisterService() fails
specifically because the service is not known anymore, and verify that
the identifier can be registered again — previously it stayed taken by
the vanished client's service forever, failing with
DNSSD_SERVICE_EXISTS.

A dummy link with mDNS enabled makes sure the per-scope goodbye/zone
teardown path actually runs, and since resolved would be restarted
automatically if it crashed in it, letting the D-Bus level checks pass
vacuously, verify the InvocationID stayed the same throughout.
2026-09-02 10:41:54 +02:00
Stefan Agner 11e4e35f4c resolved: actually unregister DNS-SD services when the bus client vanishes
Since the D-Bus DNS-SD API was introduced in c3036641f0 ("resolved:
implement D-Bus API for DNS-SD", v236), RegisterService() has set up an
sd_bus_track object so that a registered service is destroyed when the
client that registered it disconnects from the bus — there's even a
handler logging "Client of active request vanished, destroying DNS-SD
service."

However, the track object was never stored anywhere: it is declared as
a _cleanup_(sd_bus_track_unrefp) local in bus_method_register_service()
and hence destroyed again when the method handler returns, taking the
tracking down with it. The vanish handler was thus dead code, and
services registered via D-Bus silently persisted after their client
disconnected — unowned, impossible to re-register (the identifier
stays taken, failing with DNSSD_SERVICE_EXISTS), and advertised until
systemd-resolved itself exited.

Store the track object in DnssdRegisteredService, pinning it for the
lifetime of the service, so that client tracking works as originally
intended. Route the vanish path through the full unregistration logic
(goodbye packets + removal from the per-link mDNS zones), since freeing
the service alone would leave its RRs published in the zones.

Note for fire-and-forget clients (e.g. one-shot busctl/gdbus calls):
these were never reliable — the registration silently vanished on any
resolved restart — and now behave as documented for the corresponding
Avahi API as well: the bus connection must be kept open for as long as
the service is to remain registered. Document that in the man page and
NEWS, and point to *.dnssd files for registrations independent of a
client's lifetime.
2026-09-02 10:40:34 +02:00
Stefan Agner a3a8e82f25 resolved: only send goodbye for the RRs of the service being unregistered
dns_scope_announce(scope, /* goodbye= */ true) is not scoped to a
specific service: it walks the whole per-link mDNS zone and flags every
established RR as goodbye (TTL 0). Unregistering a single DNS-SD
service via the UnregisterService() D-Bus call hence withdrew the
host's own A/AAAA records and every other published service on the
link from remote caches, with nothing re-announcing them afterwards.

Introduce dns_scope_send_goodbye(), which sends an unsolicited response
for a caller-provided RR set, and let the DNS-SD unregistration path
send goodbye only for the RRs of the service actually being removed,
mirroring the flag logic of dns_scope_announce().

The goodbye answer is built per scope, and only includes records
actually established in the respective zone (or under re-verification,
in which case they are still served from it): a per-service goodbye
must take care not to withdraw records that are still being probed for
uniqueness, were withdrawn again after a conflict (in which case the
name belongs to the neighbor), or were never published in the scope in
the first place (e.g. on MulticastDNS=resolve links, which have an mDNS
scope but do not publish DNS-SD services).

This becomes more important with the next commit, which promotes
unregistration from an explicit method call to an automatic consequence
of the registering client disconnecting from the bus.
2026-09-02 10:40:34 +02:00
Luca Boccassi 25c0b10671 mkosi: update debian commit reference to 70dd6c36578ecaa214992f54701eeedaa3b57aed
* 70dd6c3657 Update changelog for 262~rc1-2 release
* 84ccf4ddbf Install 60-tpm2-id.rules on all architectures
* 20cd9d23cf Update changelog for 262~rc1-1 release
* e479c1d28e Update d/copyright
* fac1cd6d40 Update Lintian overrides for new units
* 448fa0e577 Update symbols file for upstream release
* dd467c4e44 Install new files for upstream build
* cbcc96360e d/systemd.links: stop creating cryptdisks{,-early}.service masks (LP: #2153836)
2026-09-02 12:13:42 +09:00
Tobias Heider d2a5296298 boot: Update aa64 hwids
Sync the latest hwid database from Ubuntu stubble

Signed-off-by: Tobias Heider <tobias.heider@canonical.com>
2026-09-01 18:13:50 +01:00
Armaan Sandhu 65c112007a fuzz: add a fuzzer for the qcow2 converter
systemd-importd runs qcow2_detect()/qcow2_convert() over images it has just
downloaded (see pull-raw.c), so the header, the L1/L2 tables and every offset
and cluster descriptor in them are attacker controlled. There is a manual test
for the happy path, but nothing that feeds it a malformed image.

The corpus is two images, a plain data cluster and a zlib-compressed one (i.e.
decompress_zlib_raw()), at the 512 byte minimum cluster size and trimmed to the
last byte the converter reads, so 2K each. A zero cluster and a QCOW3 header are
a flipped descriptor bit and a bumped version field away from these, so they are
left to the fuzzer rather than carried in the tree.
2026-09-01 11:41:19 -04:00
Armaan Sandhu 43cd946f98 fuzz: add a fuzzer for the decompression entrypoints
fuzz-compress only ever feeds the decompressors their own output: it compresses
the fuzzer input and then decompresses the result, so the stream the decoders
see is well formed by construction. The blobs they get in reality come out of
journal files, systemd-journal-remote streams, coredumps and downloaded images,
i.e. from wherever the data was written, which is not necessarily somewhere we
trust.

So hand them the fuzzer input directly instead, across all four entrypoints:
decompress_blob(), decompress_startswith(), decompress_stream(), and the
decompressor_detect()/decompressor_push() pair that systemd-importd feeds from
the network. The latter is pushed in chunks, so that the decoders see the same
fragmentation a real download produces. The decompressed size is capped, as an
unbounded decode of a hostile blob measures the allocator rather than the
decoder.

The corpus carries the two truncated stream headers that used to send
decompress_startswith() allocating until OOM, fixed in the previous commit.
2026-09-01 11:41:19 -04: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
Lucas Adriano Salles 41d4263f50 hwdb: fix Positivo N15WPE-S and N15RPE-S key toggle touchpad and search key (#43602)
Fixes #43601
2026-09-02 00:07:34 +09:00
Armaan Sandhu 87d3c04672 compress: don't grow the output buffer forever on a truncated stream
decompress_startswith() decodes just enough of a blob to compare its leading
bytes against a prefix, and grows the output buffer whenever a round of
decoding came back with less than prefix_len + 1 bytes decoded. That growth is
only the right answer while the decoder actually wants more output room. If it
instead ran out of input, i.e. the stream is truncated, then no amount of extra
room will help, and the gzip and bzip2 paths double their allocation on every
iteration until the process is out of memory.

Neither decoder lets us tell the two cases apart by return code alone:
inflate() reports the stalled stream as Z_BUF_ERROR, which we cannot simply
refuse since that is also how it asks for a bigger output buffer, and
BZ2_bzDecompress() does not distinguish them at all, it just keeps saying
BZ_OK. The output space left over does tell us, though: a decoder that stopped
without filling the buffer we gave it is waiting for input that is not coming,
so report the stream as corrupt instead of growing.

A 10 byte gzip header, or a 4 byte bzip2 header, with nothing behind it was
enough to reach a single 4 GiB allocation this way. The xz and zstd paths
already terminate, the former because liblzma turns a stalled stream into
LZMA_BUF_ERROR.

Note that no caller can reach this today: the only non-test caller is
decompress_startswith_journal(), and compression_supported_journal() admits
only NONE/XZ/LZ4/ZSTD. It is a trap for whoever wires up the other two, so
let's close it now.
2026-09-01 10:02:52 -04:00
Zbigniew Jędrzejewski-Szmek c47a5fa25b hostname-wordlist: fix comment and downgrade warning
The comment was wrong. The average word is about 6 characters, so in
64 iterations, the probability of never landing on a word boundary is
~(1 - 1/7)**64, about 0.01%.
2026-09-01 15:57:58 +02:00
Zbigniew Jędrzejewski-Szmek c737b297a3 hostname-setup: read the whole wordlist into memory when picking words
hostname_pick_word() used to seek around in the wordlist file and read
individual lines with read_line()/read_stripped_line(). Instead, slurp the
whole file into memory use offset arithmetic. The wordlists are small, so
reading them entirely is faster and there is really no reason to do the
complicated thing. The new code is 15% faster (the slow parts are the
hashing and chaseat, they actually dominate over the reading of the data).
The "raced with truncation" case is gone, since the buffer is a consistent
snapshot of the file.

The random offsets derived from the machine ID are unchanged, so the
picked words stay the same.
2026-09-01 15:57:58 +02:00
Zbigniew Jędrzejewski-Szmek 00d512bdce basic/fileio: wrap long comments 2026-09-01 15:57:58 +02:00
Zbigniew Jędrzejewski-Szmek 96de029ad7 basic/path-util: stop ignoring non-absolute paths
112cfb1814 tried to improve handling of
paths when root is specified. It said:
> To avoid answering what a relative path means when called with a root
> prefix path_strv_canonicalize is now path_strv_canonicalize_absolute
> and only considers absolute paths. Fortunately all users of already call
> path_strv_canonicalize with a list of absolute paths.

Of course, other users were added later and for example now
SYSTEMD_HOSTNAME_WORDLIST_PATH=build/hostname-wordlist/ ... doesn't
work as expected. If root is not specified, there is really no reason
to ignore relative paths. They work relative to CWD per the usual convention.
It's up to the user to not use relative paths in a context where they
should not be used. When root is specified, continue to ignore the relative
paths, since there is no clear interpreation what they mean, but emit
a debug message.
2026-09-01 15:57:58 +02:00
Zbigniew Jędrzejewski-Szmek 6ec548c336 shared/fileio: avoid copying strv twice
search_and_fopen called search_and_fopen_internal which made a copy
of the search strv and then called search_and_open which made a copy
too.
2026-09-01 15:57:58 +02:00
Zbigniew Jędrzejewski-Szmek 98dbda7a2c test-hostname-pick-word: add a simple test to check word selection
This is useful to check if how fast the code is (painfully slow) and whether
worlds indeed are selected with a flat distribution probability (they are).

The code is slow because the hashing and because chaseat is exteremely
inefficient :(
2026-09-01 15:55:45 +02:00