Commit Graph
58746 Commits
Author SHA1 Message Date
Ronan Pigott 27eedfa0ef resolved: use the SOA to find chain of trust quicker
sd-resolved does dnssec "backwards" compared to most resolvers.

A typical strategy is to start from the DNS root and gather the
requisite keys on the way down, but sd-resolved requests the final
answer it wants and then goes searching for the requisite keys later.

We don't know in advance under which names we should expect to find
those keys, because we don't know the zone cuts a priori, but we can use
what we have found in prior responses to make an educated guess. This
was more or less the intent of 47690634f1, but it was partially
regressed in d840783db5 while fixing a bug handling totally empty
responses.

Fixes #37472

Ref: 47690634f1 ("resolved: don't request the SOA for every dns label")
Fixes: d840783db5 ("resolved: always progress DS queries")
2026-03-25 11:32:51 +01:00
Frantisek Sumsal f912de9312 homectl: apply all --member-of= groups from a comma-separated list
Commit 0e1ede4b4b introduced a bug where
we'd always fetch the "original" (empty) list of groups when processing
a comma-separated list of groups from the --member-of= option, so only
the last group from the list would get applied. This bug was then later
(in 316e9887f2) refactored into a separate
function.

Follow-up for 0e1ede4b4b.
Resolves: #41286
2026-03-25 10:41:06 +01:00
Zbigniew Jędrzejewski-Szmek 2e31b9eb29 resolved: resolve insecure answers with unsupported sig algorithms (#40778)
sd-resolved does not support all the permissible DNSSEC signature
algorithms, and some are intentionally unsupported as a matter of
policy. Answers that can only be validated via unsupported algorithms
should be treated as if they were unsigned, per RFC4035 § 5.2.

Previously, sd-resolved tried to properly record insecure answers for
unsupported algortihms, but did not record this status for each of the
auxilliary DNSSEC transactions, so the primary transaction had no way to
know if there was a plausible DNSKEY with an unsupported signature
algorithm in the chain of trust.

This commit adds the insecure DNSKEYs that use unsupported algorithms to
the list of validated keys for each transaction, so that dependent
transactions can learn that a plausible chain of trust exists, even if
no authenticated one does, and report the insecure answer.

This should improve the situation in #35126.
2026-03-25 10:38:08 +01:00
Lennart Poettering 4b6893bdc8 resolved: add "static RRs" concept (#41213)
split out of #40980
2026-03-24 22:45:22 +01:00
Daan De Meyer 4c02d63b36 vmspawn: Fix --help width 2026-03-24 22:43:44 +01:00
Lennart Poettering fb17ad1581 vmspawn: add disk type selection for root and extra drives (#41301)
vmspawn previously hardcoded virtio-blk for all drives. This adds
  --image-disk-type= to select the root disk type (virtio-blk,
  virtio-scsi, or nvme) and allows per-drive overrides via a
  colon-separated prefix on --extra-drive=. The format and disk type
  prefixes can appear in any order since their value sets don't overlap.

  For virtio-scsi, a single shared controller is created with drives
  attached as scsi-hd devices. For nvme, each drive gets its own
controller. Both have serial number length limits (30 and 20 characters
  respectively), so long filenames are replaced with a truncated SHA-256
  hex digest.
2026-03-24 21:48:00 +01:00
Daan De Meyer a8c2aa9e2f vmspawn: Add headless console support 2026-03-24 21:36:19 +01:00
Lennart Poettering 0718a21c13 resolved: add ability to define additional local RRs via drop-ins
This is an extension of the /etc/hosts concept, but can provide any kind
of RRs (well, actually, we only parse A/AAAA/PTR for now, but the
concept is open for more).

Fixes: #17791
2026-03-24 21:24:48 +01:00
Lennart Poettering 7ad4411a61 resolved: also flush /etc/hosts on reload
When we are told to reload our configuration also flush out /etc/hosts
explicitly. This is particularly relevant since we suppress too frequent
reloads, and hence a synchronous way to force a reload is very useful.
2026-03-24 21:24:47 +01:00
Lennart Poettering 2f1bbebeb9 dns-rr: add dns_resource_record_from_json()
This only parses a small subset of RR types for now, but we can add more
later.

Covered are the most important RR types: A, AAAA, PTR.
2026-03-24 21:24:47 +01:00
Lennart Poettering 333a9a91ef dns-rr: tighten rules on parsing RR keys from JSON
let's ensure the name is actually a valid DNS name.
2026-03-24 21:24:47 +01:00
Lennart Poettering 9eb207356c json-util: add json_dispatch_in6_addr() 2026-03-24 21:24:47 +01:00
Lennart Poettering 3839f5efec json-util: optionally accept string-based serialization for IPv4 addresses 2026-03-24 21:24:47 +01:00
Lennart Poettering 172ae47e65 stat-util: introduce inode_unmodified_hash_ops
This is almost the same as inode_hash_ops, but also hashes + compares
all attributes that could affect the contents of a file. It ignores
"superficial"/"external" attributes such as ownership or access mode
however.
2026-03-24 21:24:47 +01:00
Lennart Poettering cf6f65c5ea stat-util: also include inode type in hash ops
This doesn't really have any major benefit, but it does make this nicely
mirror stat_inode_same() which also checks this triplet for identifying
identical inodes.
2026-03-24 21:21:10 +01:00
Christian Brauner b76e1732f7 vmspawn: add nvme disk type support
Extend --image-disk-type= and the --extra-drive= disk type prefix to
support nvme in addition to virtio-blk and virtio-scsi:

  systemd-vmspawn --image-disk-type=nvme --image=image.raw
  systemd-vmspawn --image=image.raw --extra-drive=nvme:data.raw

The NVMe serial number is limited to 20 characters by the NVMe spec.
If the image filename exceeds this, it is hashed with SHA-256 and
truncated to 20 hex characters via the disk_serial() helper introduced
in the previous commit.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2026-03-24 16:53:41 +01:00
Christian Brauner e4a58c38e9 vmspawn: add virtio-scsi disk type support
Add --image-disk-type= to select the disk type for the root disk, and
allow specifying the disk type as a colon-separated prefix on
--extra-drive=:

  systemd-vmspawn --image-disk-type=virtio-scsi --image=image.raw
  systemd-vmspawn --image=image.raw --extra-drive=virtio-scsi:data.raw

For --extra-drive=, the format and disk type prefixes can appear in any
order since the value sets don't overlap:

  --extra-drive=raw:virtio-scsi:/path
  --extra-drive=virtio-scsi:raw:/path

Extra drives inherit --image-disk-type= by default unless overridden
with an explicit prefix.

vmspawn originally used virtio-scsi for all drives but switched to
virtio-blk in 1f24a954e4 for simplicity and direct kernel boot
compatibility. This makes virtio-scsi available again as an explicit
option for cases where a SCSI storage topology is desired.

For virtio-scsi, a shared virtio-scsi-pci controller is created and
drives are attached as scsi-hd devices. The SCSI serial number is
limited to 30 characters, so filenames exceeding this are hashed with
SHA-256.

Signed-off-by: Christian Brauner <brauner@kernel.org>
2026-03-24 16:53:40 +01:00
Lennart Poettering 48ca2f6ff5 discover-image: remove tpm state + efi nvram state on image removal 2026-03-24 14:42:39 +01:00
Lennart Poettering dc91cb82da vmspawn: split out swtpm-setup logic, and beef it up a bit 2026-03-24 14:42:39 +01:00
Lennart Poettering 9996cfd2c9 vmspawn: manage EFI nvram (variables) state similar to TPM state 2026-03-24 14:40:08 +01:00
Lennart Poettering 5cd3462014 vmspawn: make efi variable nvram dependent on whether the EFI profile knows the concept, not on secureboot 2026-03-24 14:40:08 +01:00
Daan De Meyer da580dc161 vmspawn: Drop --sandbox=chroot from virtiofsd command line
It's unclear why I added this in fd05c6c759,
but it breaks bind mounting regular directories via --bind,
so drop it again since it's not actually required to make virtiofsd
work with the foreign UID range.
2026-03-24 11:21:02 +00:00
Luca Boccassi 3af158759f creds: use CLEANUP_ERASE for symmetric key
Just in case, ensure the sha256 that is used as a symmetric
key for encrypted creds is safely erased from memory.

Reported on yeswehack.com as YWH-PGM9780-166

Follow-up for 21bc0b6fa1
2026-03-24 08:29:03 +01:00
Lennart Poettering e7a176fe46 Define options and verbs through "magic macros" (#40880)
This is an another alternative for #40656, based on @poettering's
suggestion to use an ELF section.

The output of --help is generated using format-table, but the details of
the formatting a bit off: different sections in the table (verbs, option
groups) are not aligned to the same column. Our current table formatting
doesn't make this easy. If somebody has an idea how to do this without
too much pain, please make suggestions.

Another thing that I didn't know how to do nicely, was to use the two
columns of separation. But maybe this doesn't matter. If we switch to
one column everywhere, I don't think people will care.

Example output:
```console
$ build/systemd-id128 -h | cat    
systemd-id128 [OPTIONS...] COMMAND

Generate and print 128-bit identifiers.

Commands:
  new                Generate a new ID
  machine-id         Print the ID of current machine
  boot-id            Print the ID of current boot
  invocation-id      Print the ID of current invocation
  var-partition-uuid Print the UUID for the /var/ partition
  show [NAME|UUID]   Print one or more UUIDs
  help               Show this help

Options:
  -h --help            Show this help
     --version         Show package version
     --no-pager        Do not start a pager
     --no-legend       Do not show headers and footers
     --json=FORMAT     Output inspection data in JSON (takes one of pretty,
                       short, off)
  -j                   Equivalent to --json=pretty (on TTY) or --json=short
                       (otherwise)
  -p --pretty          Generate samples of program code
  -P --value           Only print the value
  -a --app-specific=ID Generate app-specific IDs
  -u --uuid            Output in UUID format

See the systemd-id128(1) man page for details.
```

The output wraps automatically with terminal width. If the terminal is
extremely narrow, ellipsization occurs. I think this doesn't matter
and/or is actually a feature. Such narrow terminals mostly occur in
testing, so it doesn't matter what exactly we do, as long as it is
something somewhat reasonable.

Anyway, I think this is enough as PoC. Please compare this with the
previous approach. /cc @behrmann, @YHNdnzj, @poettering

The three binaries that are converted have options, verbs, optional
arguments, and options terminate option parsing, so most of the
functionality is there. One thing that I didn't implement that was
present in previous PRs is "namespaces", i.e. multiple parsers in the
same source file. I expect that we can handle this similarly to option
groups.
2026-03-23 22:17:05 +01:00
Ronan Pigott 3ddb73317e resolved: also validate unsupported dnssec digest algs 2026-03-23 13:06:19 -07:00
Ronan Pigott 053f4f1dbc resolved: resolve insecure answers with unsupported sig algorithms
sd-resolved does not support all the permissible DNSSEC signature
algorithms, and some are intentionally unsupported as a matter of
policy. Answers that can only be validated via unsupported algorithms
should be treated as if they were unsigned, per RFC4035§5.2.

Previously, sd-resolved tried to properly record insecure answers for
unsupported algortihms, but did not record this status for each of the
auxilliary DNSSEC transactions, so the primary transaction had no way to
know if there was a plausible DNSKEY with an unsupported signature
algorithm in the chain of trust.

This commit adds the insecure DNSKEYs that use unsupported algorithms to
the list of validated keys for each transaction, so that dependent
transactions can learn that a plausible chain of trust exists, even if
no authenticated one does, and report the insecure answer.
2026-03-23 13:06:19 -07:00
Lennart Poettering 5adfd44c9e copy: add new flags that cause a seek to beginning of files before copying
This is quite useful in various cases where we so far did this manually.
2026-03-23 19:19:46 +00:00
Zbigniew Jędrzejewski-Szmek 1ddc5ae3e4 notify: add one more compiler suppression
Old gcc (<14) says:

2026-03-02T23:11:28.5676353Z In file included from ../src/notify/notify.c:30:
2026-03-02T23:11:28.5694607Z In function ‘strv_isempty’,
2026-03-02T23:11:28.5695481Z     inlined from ‘action_fork’ at ../src/notify/notify.c:440:9,
2026-03-02T23:11:28.5696266Z     inlined from ‘run’ at ../src/notify/notify.c:541:24,
2026-03-02T23:11:28.5696929Z     inlined from ‘main’ at ../src/notify/notify.c:682:1:
2026-03-02T23:11:28.5697877Z ../src/basic/strv.h:108:23: error: ‘args’ may be used uninitialized [-Werror=maybe-uninitialized]
2026-03-02T23:11:28.5698655Z   108 |         return !l || !*l;
2026-03-02T23:11:28.5699052Z       |                       ^~
2026-03-02T23:11:28.5700020Z ../src/notify/notify.c: In function ‘main’:
2026-03-02T23:11:28.5700681Z ../src/notify/notify.c:531:16: note: ‘args’ was declared here
2026-03-02T23:11:28.5701217Z   531 |         char **args;
2026-03-02T23:11:28.5701574Z       |                ^~~~
2026-03-02T23:11:28.5701960Z cc1: all warnings being treated as errors
2026-03-23 14:20:10 +01:00
Zbigniew Jędrzejewski-Szmek 8b89c6a64b Apply the same column width for different option groups
This feel a bit like a hack, but it works OK. The width of the first
column of verbs or options in different sections is measured and
applied to the other tables. This makes the second column aligned.
2026-03-23 14:20:10 +01:00
Zbigniew Jędrzejewski-Szmek bcaa5acf81 shared/format-table: add helpers to query and set column width 2026-03-23 14:20:10 +01:00
Daan De Meyer 6fb5ec3dd1 ci: Replace codeql PotentiallyDangerousFunction query with clang-tidy (#41246) 2026-03-23 11:30:47 +01:00
Daan De Meyer 4d8e090763 Two fixlets (#41273)
From yeswehack.com reports
2026-03-23 09:05:27 +01:00
Yu Watanabe 218ae1b11f networkd: replace D-Bus with Varlink in networkctl (#40780)
networkctl previously called networkd over D-Bus for several operations.
This replaces all of those calls with Varlink, making it the sole IPC
mechanism between networkctl and networkd.

 New Varlink methods added to networkd:

- io.systemd.Network.Link (new sub-interface for link-specific
operations):

- Link.Describe — replaces Link.BitRates + DHCPServer.Leases D-Bus
properties
- Link.Up — replaces Link.SetUp D-Bus method (moved from
**io.systemd.Network.LinkUp**)
- Link.Down — replaces Link.SetDown D-Bus method (moved from
**io.systemd.Network.LinkDown**)
      - Link.Renew  — replaces Link.Renew D-Bus method
      - Link.ForceRenew   — replaces Link.ForceRenew D-Bus method
      - Link.Reconfigure  — replaces Link.Reconfigure D-Bus method

  - io.systemd.service 
     - Reload            — replaces Manager.Reload D-Bus method

  Supporting changes:
- link_get_bit_rates() extracted from networkd-link.c into
networkd-speed-meter.c
- BitRates added to link_build_json() so Link.Describe returns them
inline
alongside the existing interface description, replacing a separate D-Bus
read
- link_reconfigure_full() and manager_reload() extended to accept
sd_varlink*
for deferred async replies (consistent with existing sd_bus_message*
path)
  - DHCP lease display (networkctl status) uses Link.Describe instead of
DHCPServer.Leases; falls back to ClientId when hostname is not present
2026-03-23 14:55:57 +09:00
Luca Boccassi 7b148d7b78 mountfsd: fix readOnly flag inversion
mountfsd applies R/O when the varlink readOnly flag is set to false

Reported on yeswehack.com as YWH-PGM9780-164

Follow-up for 702a52f4b5
2026-03-23 00:54:51 +00:00
Luca Boccassi aaac2d3eda core: also set iov_len when deserializing LogExtraFields=
This is not actually used so it doesn't really matter in
practice and the fields are used anyway, but for cleanliness
fix it

Reported on yeswehack.com as YWH-PGM9780-165

Follow-up for 5699a1689b
2026-03-23 00:54:23 +00:00
Daan De Meyer 8878df45c1 ssh: handle VMADDR_CID_ANY in a couple places (#41230)
Originally reported in Ubuntu as
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2145027.
2026-03-22 20:07:53 +01:00
Daan De Meyer 2bc0b826dc [RFC] core: add io.systemd.Manager.{PowerOff,SoftReboot,Halt,Kexec} (#41236) 2026-03-22 20:06:34 +01:00
Andreas K. Hüttel beef155b12 mips: Fix conditional inclusion of <asm/sgidefs.h>
systemd now has a system call wrapper that does a long series of #ifdef's to
differentiate between architectures and ABIs. This wrapper has two problems.

1. On mips, it needs to differentiate between O32, N32, N64 ABI. It does that
via a code block in src/include/override/sys/generate-syscall.py (and derived
files):

     76 #  elif defined(_MIPS_SIM)
     77 #    if _MIPS_SIM == _MIPS_SIM_ABI32
     78 #      define systemd_NR_{syscall} {nr_mipso32}
     79 #    elif _MIPS_SIM == _MIPS_SIM_NABI32
     80 #      define systemd_NR_{syscall} {nr_mips64n32}
     81 #    elif _MIPS_SIM == _MIPS_SIM_ABI64
     82 #      define systemd_NR_{syscall} {nr_mips64}
     83 #    else
     84 #      error "Unknown MIPS ABI"
     85 #    endif
     86 #  elif defined(__hppa__)

Now the _MIPS_SIM* constants stem from a vendor-specific header file sgidefs.h,
which is included with glibc, but not with musl. It is however always present
in the Linux kernel headers as asm/sgidefs.h ...

2. To work around this, the syscall wrapper already has a block

     47 #ifdef ARCH_MIPS
     48 #include <asm/sgidefs.h>
     49 #endif

Turns out, ARCH_MIPS is defined nowhere in Gentoo, neither on glibc nor on musl.
As a result the code (by accident, probably sgidefs.h is included transitively
somehow) works on glibc, but not on musl.

The simplest fix is to replace line 47 in the generator and the derived file
with

     47 #ifdef __mips__

Two other source code files require a similar fix since they rely on the
constants.

Bug: https://github.com/systemd/systemd/issues/41239
Bug: https://bugs.gentoo.org/971376
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2026-03-22 20:02:13 +01:00
Daan De Meyer 9d844012bc sd-dhcp-client: several trivial cleanups (#41256) 2026-03-22 20:00:33 +01:00
Yu Watanabe 55f2fdd508 dhcp: fix user class and vendor specific option assignment
The commit 6d7cb9a6b8 fixes the assignment
of the these options when specified through SendOption=. However, it
breaks when specified through UserClass= or SendVendorOption=.

When UserClass= or SendVendorOption= is specified, the option length is
calculated from the sd_dhcp_client.user_class or .vendor_options. Hence,
we can use 0 for the length in that case.

Follow-up for 6d7cb9a6b8.
2026-03-22 19:40:54 +01:00
Frantisek Sumsal 924f5a3461 sd-varlink: gracefully reject arrays/maps with a null element
Follow-up for 799392286e.
2026-03-22 19:37:47 +01:00
Zbigniew Jędrzejewski-Szmek 57a1f1ab96 bus-error: fix typo 2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 95ee4fd2cc notify: add one more assert
We tend to get those preallocated array sizes wrong.
In this case, the count was correct, but add the usual
assert.
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 0e4459eb19 notify: use the new option parser
Cosmetic adjustments to one help string.
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 08f7a4865e dissect: restore compat with clang
clang says:
  src/dissect/dissect.c:292:17: warning: label followed by a declaration is a C23 extension [-Wc23-extensions]

Another option would be to raise the C standard to C23. I think that'd
make sense, but it's better to do it separately.
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 34fba9e561 dissect: use the new option parser
Some cosmetic differences in descriptions are made.
--quiet was miscategorized as a command (172fadda65),
--usr-hash and --usr-hash-sig were not listed (10b8d65f3f).
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek cefec0b67d id128: use the new option parser
--version was not documented. Fixup for 0d1d512f7f.
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek e13b7872e0 options: only consume "--" immediately after an option that stops parsing
The behaviour that was implemented in systemd-dissect was that
both '--exec -- cmd' and '--exec cmd' result in 'cmd' as the command,
and '--' anywhere later is as a positional argument, so nesting is
possible, e.g.:
  --exec -- cmd --opt -- another-cmd --another-opt

This is not obvious, so add some tests for this and keep it as a separate
commit.
2026-03-22 16:52:22 +01:00
Zbigniew Jędrzejewski-Szmek 4bf73e6980 test-options: add tests for option macros and flags
Add tests for OPTION_STOPS_PARSING, OPTION_GROUP_MARKER, and
OPTION_OPTIONAL_ARG flags with manual Option arrays, and a separate
test exercising the OPTION, OPTION_LONG, OPTION_SHORT, OPTION_FULL,
and OPTION_GROUP macros via FOREACH_OPTION_FULL in a switch statement,
as they would be used in real code.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 16:52:22 +01:00
Michael Vogt 114c89cc94 core: allow unset pidref in manager_log_caller
This commit allows unset pidref when calling manager_log_caller().
With that we can log manager calls even if we cannot resolve the
caller. Currently when we cannot resolve the caller we are just
not logging anything. With this commit we at least log the call
(even though we don't know what caller it was).

Thanks to keszybz for the suggestion.
2026-03-21 22:40:52 +01:00