Commit Graph

9302 Commits

Author SHA1 Message Date
Lennart Poettering
4f3a3b7695 sd-boot: also read type #1 entries from SMBIOS Type #11
With this we can now do:

systemd-vmspawn -n -i foobar.raw -s io.systemd.boot.entries-extra:particleos-current.conf=$'title ParticleOS Current\nuki-url http://example.com/somedir/uki.efi'

Assuming sd-boot is available inside the ESP of foobar.raw a new item
will show up in the boot menu that allows booting directly into the
specified UKI.
2025-02-21 10:04:15 +01:00
Lennart Poettering
89cecfb100 vmspawn: add --smbios11= switch for passing arbitrary smbios type #11 strings to vm 2025-02-21 10:04:15 +01:00
Lennart Poettering
f8825c1364 udev-builtin-blkid: use loopback block device 'ref' field fo determining gpt-auto whole block device
So far the gpt-auto logic only looked for the partition table of devices
that the ESP/XBOOTLDR partition used to boot was on. This works great
for local boots, but is more problematic if we boot a UKI via UEFI HTTP
boot, because there is no ESP in play in that case.

Let's introduce an alternative to communicate the intended default root
disk to cover for this situation: any loopback block device whose
backing file field (i.e. the userspace controlled freeform field we use
for /dev/disk/by-loop-ref/ naming) is set to "rootdisk" will be consider
for gpt-auto will be consider for gpt-auto.

With this in place we should have nice automatic behaviour:

1. If we are booted locally we'll get the ESP/XBOOTLDR data, and derive
   the root disk from that.

2. If we are booted via UEFI HTTP boot we expect that the caller makes
   the loopback device appear with the right loop-ref identifier, and
   then will use that.
2025-02-21 10:03:49 +01:00
Lennart Poettering
fe72166979 fstab-generator: validate root= and mount.usr= the same way
In both cases, let's check for the same special mount sources. We
already covered some of the same, but let's just make it the same
codepaths.
2025-02-21 10:03:32 +01:00
Lennart Poettering
b4bee5684d fstab-generator: support creating bind mounts via root= kernel cmdline switches
This is useful for bind mounting a freshly downloaded and unpacked tar
disk images to /sysroot to mount into.

Specifically, with a kernel command line like this one:

  rd.systemd.pull=verify=no,machine,tar:root:http://_gateway:8081/image.tar root=bind:/run/machines/root ip=any

The first parameter downloads the root image, the second one then binds
it to /sysroot so that we can boot into it.
2025-02-21 10:03:32 +01:00
Lennart Poettering
8b918a3a38 import-generator: optionally import images into /run/ hierarchy rather than /var/
This is useful in particular in the initrd, as this ensures any
downloaded images are not deleted during the initrd→host transition
(where /var/ does not survive, but /run/ does). Might be useful in other
cases too, for example for transiently deployed confexts and such.
2025-02-21 10:03:32 +01:00
Lennart Poettering
0c892214f7 import-generator: add new option 'bootorigin' to derive URL from efi boot url 2025-02-21 10:03:32 +01:00
Lennart Poettering
e15d18b4c6 sd-stub: if we are http booted, query source URL and write to EFI variable
This way userspace can read the field, and use it to retrieve more
resources from the same place.
2025-02-21 10:03:32 +01:00
Lennart Poettering
c88fdb1e56 import-generator: optionally create loopback devices after download
This is useful for booting from a freshly downloaded disk image: just
specify

    rd.systemd.pull=verify=no,machine,blockdev,raw:image:https://192.168.100.1:8081/image.raw
    root=/dev/disk/by-loop-ref/image.raw-part2

on the kernel command line, and we'll download that in the initrd and boot from it.

(note the above disables download-time verification, putting trust in
verity and image policy that this won#t do harm)

Here's a more complete example. From a git checkout do:

    ninja -C build && mkosi -f -T serve

and then from another terminal do within the same checkout:

    ./build/systemd-vmspawn \
            --ram=16G \
            --register=no \
            -n \
            -i ./build/mkosi.output/image.raw \
            rd.systemd.pull=verify=no,machine,blockdev,raw:image:http://192.168.100.1:8081/image.raw \
            root=/dev/disk/by-loop-ref/image.raw-part2 \
            rootflags=x-systemd.device-timeout=infinity \
            ip=any

This will then boot via the ESP of the specified image, then download
the image via HTTP from the mkosi instance running in the first
terminal, attach it to a loopback block device, and then use its second
partition as root fs, and boot into it.

(this assumes your host is 192.168.100.1, of course)

Note that downloading the full image takes a bit of time (this downloads
it uncompressed after all), hence we turn off the timeout to wait for
the device.

This also introduces a new "imports.target" unit (and associated
"imports-pre.target") between imports are grouped, and which ensure the
imports actually are ordered correctly both on the host and in the
initrd.
2025-02-21 10:03:32 +01:00
Lennart Poettering
3e6a3341ac man: mention 'rd.' prefix for import-generator kernel cmdline options 2025-02-21 09:57:02 +01:00
Lennart Poettering
50063d496d units: add generic service for attaching a file to a loopback device
This is mostly just a friendly unit wrapper around "systemd-dissect
--attach".

This is useful so that we can automatically attach disk images as
block device at boot.
2025-02-21 09:57:02 +01:00
Lennart Poettering
172fadda65 dissect: add --quiet mode 2025-02-21 09:57:02 +01:00
Lennart Poettering
6b3fd03eac dissect: optionally derive loop-ref from image filename 2025-02-21 09:57:02 +01:00
Lennart Poettering
9b2b7625d2 Some minor improvements to D-Bus docs (#36467)
See the commit messages for details:
 - Fix some confusing wording
 - Clarify about signal emission on convenience objects for login1
2025-02-20 20:48:55 +01:00
Daan De Meyer
f1f28bbbb7 Fix race in io.systemd.Machine.Open() test case (#36410)
This started out as a simple attempt to fix a race in an existing test
case for io.systemd.Machine.Open(). To address it nicely I added some
machinery to varlinkctl and systemd-notify though, and because of that I
refacting reception of sd_notify() messages in various places of our
codebase. So it became much much bigger.

This ports all receivers of sd_notify() messages over to a new common
implementation, except for one: the one in PID1. It's more powerful than
the others, since it accepts fds too. I think we should generalize
notify_recv() to cover that too, it's not that much more work, but for
now I didn't want to add even more refactorings on top, and this can
easily happen later separately, hence I left it out for now.
2025-02-20 19:53:00 +01:00
Philip Withnall
82b32b997c docs: Clarify that login1 signals are not emitted for convenience objects
While this is obvious if you spend a few minutes thinking about how
D-Bus signals work (in this case, they are broadcast from a system
service, so cannot apply to a specific user/session/seat), it’s a bit
easy to overlook this while putting code together which uses the login1
D-Bus API, so it’s helpful to point this hazard out specifically in the
docs.

The signals can only be emitted on the canonical objects. The
convenience objects are useful for method calls, as the calling context
can be used to dereference ‘self’ and ‘auto’, but this can’t work for
signals.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-20 18:18:56 +00:00
Philip Withnall
5fe4edd3fc docs: Fix some confusing wording in various D-Bus docs
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-20 18:13:21 +00:00
Lennart Poettering
25ec3fdfd3 core: also check boot ID and product UUID in ConditionHost=
Sometimes it's interesting to condition units not just on the
installation but on the physical device. Let's make ConditionHost=
useful for that kind of checks, and while we are at it, also allow it to
be used for condition checks on the boot id.

Overloading like this is safe, since UUIDs are globally unique after
all, and hence there should be no conflicts between the namespace of
boot ids, machine ids and product ids.

Finally, relax rules on uuid checking: if the specified string parses
as uuid or id, also check it against the hostname, for setups where
people name hosts after uuids. I wouldn't know why anyone would do that,
but also, why not? shouldn'rt hurt allowing them and should not create
ambiguity conflicts.
2025-02-20 18:13:38 +01:00
Lennart Poettering
fd2d435d97 varlinkctl: introduce new --exec switch
This new switch makes it possible to process fds attached to a varlink
reply: if specified it will execute a command line specified by the
caller, will pass the response json as stdin, and any fds acquired as
fd3, fd4, …
2025-02-20 18:12:12 +01:00
Lennart Poettering
4389e4c2ae notify: add a new --fork verb that implements a minimal receiver side for sd_notify() messages 2025-02-20 18:11:31 +01:00
Ahmad Fatoum
6f8a9d0917 man: fix typo in systemd.watchdog_device kernel option
The option that systemd actually looks for has an underscore and no dash
as can be seen in src/core/main.c.

The man/kernel-command-line.xml documentation also gets it right with
this file being the only instance of watchdog-device being used.

Fixes: c75396c30b ("documentation: add description for watchdog device path")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
2025-02-20 12:18:45 +00:00
Luca Boccassi
5dbc4f37c5 tree-wide: tweaks to mount point inode creation (#36308)
Some love for make_mount_point_inode_from_xyz() and ports PID 1 over to
it for mount units.

Alternative to #36290
2025-02-19 22:09:52 +00:00
Luca Boccassi
4225242149 repart: add parameter to attach offline verity signature (#36405)
Add --join-signature=hash:sig - when a verity signature partition
has been deferred in a previous run, this allows attaching a signature
that was created offline, for example on a build system like OBS where
the private key is not available to the build process.

Can be specified multiple times, the right partition to act upon will
be selected by matching the data+verity partitions UUIDs with the
provided roothash(es)
2025-02-19 18:12:19 +00:00
Luca Boccassi
09fd125059 repart: add parameter to attach offline verity signatures
Add --join-signature=hash:sig - when a verity signature partition
has been deferred in a previous run, this allows attaching a signature
that was created offline, for example on a build system like OBS where
the private key is not available to the build process.

Can be specified multiple times, the right partition to act upon will
be selected by matching the data+verity partitions UUIDs with the
provided roothash(es)
2025-02-19 16:26:05 +00:00
Steve Ramage
a4750ae156 network: doc and code typo fixes (#36422)
This fixes some typos in the documentation, both grammar as well as
incorrect field names.
It also changes the casing of CheckSum to Checksum in L2TP to match
other casings.
2025-02-19 02:08:16 +09:00
Lennart Poettering
4e24796b5a mount-tool: add explicitly control of path canonicalization
With this the default canonicalization of paths can be turned off,
giving users explicit control on what shall happen if symlinks are
encountered within a path.
2025-02-18 13:49:24 +01:00
Marco Trevisan (Treviño)
bd887a75d4 man/org.freedesktop.systemd1.xml: Clarify the behavior of Subscribe()
It was unclear that it was applied to standard signals too, and this
lead to unexpected behavior.

See: https://github.com/systemd/systemd/pull/36366
2025-02-18 09:56:11 +00:00
Daan De Meyer
42839efb10 mkfs-util: Add support for btrfs compression
Corresponding PR in btrfs-progs: https://github.com/kdave/btrfs-progs/pull/882
2025-02-17 14:11:04 +01:00
Yu Watanabe
c259c9e253 journal-remote: several follow-ups for Compression= option handling
Follow-ups for cfaf78001c.

- use OrderedHashmap to manage configured compression algorithms, then
  drop CompressionArgs,
- rename CompressionOpts -> CompressionConfig,
- refuse 'none' in Compression= setting, but accept boolean false, which
  disables compression,
- when Compression= option is unspecified, enable all supported compression
  algorithms by default,
- do not set 'none' to the Accept-Encoding header.
2025-02-16 20:08:39 +09:00
Louis Sautier
24af6a0d0a man/networkd.conf: add missing whitespace between words
Signed-off-by: Louis Sautier <sautier.louis@gmail.com>
2025-02-16 00:27:43 +01:00
Yu Watanabe
dd0d821a33 journal-remote: fix typo
Follow-ups for cfaf78001c.
2025-02-14 13:23:27 +09:00
Yu Watanabe
4053af87bb core/mount: rework GracefulOptions= as x-systemd.graceful-option= (#36356)
Prompted by #36337
2025-02-14 13:01:14 +09:00
Zbigniew Jędrzejewski-Szmek
de02b551ad core/condition: fix segfault when key not found in os-release
'ConditionOSRelease=|ID_LIKE$=*rhel*' results in a segfault.
The key 'ID_LIKE' is not present in Fedora's os-release file.

I think the most reasonable behaviour is to treat missing keys as empty.
This matches the "shell-like" sprit, since in a shell empty keys would
by default be treated as empty too. Thus, "ID_LIKE=" would match, if
ID_LIKE is not present in the file, and ID_LIKE=!$foo" would also match.
The other option would be to make those matches fail, but I think that'd
make the feature harder to use, esp. with negative matches.

Documentation is updated to clarify the new behaviour.

https://bugzilla.redhat.com/show_bug.cgi?id=2345544
2025-02-13 18:16:42 +01:00
Daan De Meyer
5ca1865ad9 sysupdate: Don't use compression extension for UKIs in manpage
UKIs should generally not be compressed since the kernel image and
initrd in them will already be compressed so let's remove the compression
suffix from the examples in the sysupdate manpage.
2025-02-13 13:08:15 +01:00
Mike Yuan
0d76f1c423 core/mount: rework GracefulOptions= to be just x-systemd.graceful-option=
09fbff57fc introduced new knob
for such functionality. However, that seems unnecessary.

The mount option string is ubiquitous in that all of fstab,
kernel cmdline, credentials, systemd-mount, ... speak it.
And we already have x-systemd.device-bound= that's parsed
by pid1 instead of fstab-generator. It feels hence more natural
for graceful options to be an extension of that, rather than
its own property.

There's also one nice side effect that the setting itself
is now more graceful for systemd versions not supporting
such feature.
2025-02-12 18:16:44 +01:00
Mike Yuan
0fa062f983 core/dbus-mount: add missing ReloadResult and CleanResult properties 2025-02-12 15:34:54 +01:00
Philip Withnall
cc0c4bc500 man: Fix a minor typo in the org.freedesktop.login1 man page
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-11 19:27:38 +01:00
Muhammad Nuzaihan Bin Kamal Luddin
81ae2237c1 resolve: add an option to explicitly disable query AAAA, SRV, MX, etc... (#34165)
Based on this patch i had submitted to RedHat
(https://issues.redhat.com/browse/RHEL-56280), i am submitting this
patch to this upstream systemd.

There is no way to explicitly enable/disable IPv6 AAAA queries.

Problem was that i am using RHEL9 and some applications does not use a
newer glibc that supports `no-aaaa` option in `/etc/resolv.conf`. So
some applications will still resolve IPv6 AAAA even with `no-aaaa`
option and it is inconsistent across the system where some work and some
don't.

So this systemd-resolved patch catch-all queries and disable IPv6 AAAA
queries for all applications in the OS by having an option
`RefuseRecordTypes=AAAA` to disable IPv6 AAAA queries.

Although https://github.com/systemd/systemd/pull/28136 tries to fix this
automatically but it still does not work with
`net.ipv6.conf.all.disable_ipv6 = 1`. Also tried with explicitly
removing the conditional and force set `family = AF_INET` and still
resolves AAAA records.

The issue is that i want to explicitly disable IPv6 AAAA queries instead
of systemd-resolved to figure out itself which address family it is
using, which always have problems.
2025-02-11 18:29:39 +09:00
Luca Boccassi
2ac8fcf656 ukify: add --pcr-certificate= parameter
Public keys and certificates are not the same, as the latter embeds more
information that the former, and other tools like sd-measure have distinct
parameters for each of them.
Add a new --pcr-certificate= parameter to ukify, and use it to pass certs
down to sd-measure, as an alternative to --pcr-public-key=. Do not allow
specifying both.
2025-02-09 22:24:00 +00:00
Yu Watanabe
52e9bc2deb journal-remote,journal-upload: added compression support (#34822) 2025-02-09 13:33:33 +09:00
Yu Watanabe
ed8063d143 udevadm-test: show result in json format (#36284)
This adds `--json=MODE` command line option to `udevadm test`.
This may be useful for parsing e.g. network interface name or device
node symlinks.

Closes #23661.
2025-02-08 15:50:04 +09:00
Yu Watanabe
c26db05640 man/udevadm: add examples to get predictable interface name and persistent device node symlinks
Closes #23661.
2025-02-08 01:39:35 +09:00
Yu Watanabe
ac722389a7 udevadm-test: allow to dump result in json format
This adds --json=MODE option for 'udevadm test' command.
When specified, all messages, except for the final result, will be
written to stderr, and the final result is shown in JSON format to
stdout. It may be useful for parsing the test result.
2025-02-08 01:39:35 +09:00
Luca Boccassi
9876e88e23 ukify: add --pcrsig and --join-pcrsig arguments to append offline signature
Add a build parameter to take an existing UKI and attach a .pcrsig section
to it. This allows one to create a UKI with a .pcrpkey section with
--policy-digest to get the json output from sd-measure, sign the digest
offline, and attach the .pcrsig section with the signature later.
2025-02-07 13:58:51 +00:00
Yu Watanabe
b92a2290c6 kernel-install: addresses post-merge comments for #36218 (#36304) 2025-02-07 21:11:03 +09:00
Yu Watanabe
41f392490e man/kernel-install: update documents for plugins
Addresses the post-merge comments in #36218.
2025-02-07 19:52:36 +09:00
Andrii Chubatiuk
cfaf78001c journal-remote: added compression, compression-level and content-encoding negotiation 2025-02-07 07:05:02 +02:00
Yu Watanabe
cdc9be29b1 udev/net: support to configure Energy Efficient Ethernet settings
Closes #36278.
2025-02-07 13:47:41 +09:00
Thorsten Kukuk
ac9edf9911 systemd-pull: support .asc and .sha256.* signature 2025-02-06 16:49:36 +01:00
Lennart Poettering
9f036cfd57 docs: document the new area functionality 2025-02-06 09:23:49 +01:00