Commit Graph

9322 Commits

Author SHA1 Message Date
Lennart Poettering
f0f5d54202 nspawn: add ability to poweroff container cleanly with ^]^]p
It's sometimes very useful to be able to terminate a container quickly
but cleanly while talking to it. Introduce a hotkey for that: ^]^]p for
powering it off. In similar style add ^]^]r for rebooting it.
2025-03-04 23:02:31 +01:00
Mike Yuan
bb12d57cd5 mount-tool: never bind to device on explicit x-systemd.device-bound=no 2025-03-03 10:45:57 +01:00
Lennart Poettering
f2b1de6f5b Revert "sd-json: add new sd_json_variant_unset_field() call"
This reverts commit b6a2df6307.

The functionality is entirely redundant, we already have
sd_json_variant_filter() which does the same, and is in fact even more
powerful, since it takes a list instead of a single field to remove.
2025-03-02 11:04:15 +00:00
Daan De Meyer
38701809a8 core: Add DelegateNamespaces= (#36532) 2025-03-01 15:18:45 +01:00
Daan De Meyer
8234cd9989 core: Add DelegateNamespaces=
This delegates one or more namespaces to the service. Concretely,
this setting influences in which order we unshare namespaces. Delegated
namespaces are unshared *after* the user namespace is unshared. Other
namespaces are unshared *before* the user namespace is unshared.

Fixes #35369
2025-03-01 13:54:58 +01:00
Lennart Poettering
250118f3f0 sbsign: Add support for offline signing (#36485)
Add new options --prepare-offline-signing, --signed-data= and
--signed-data-signature= which allow for offline signing in a
similar manner to pesign.
2025-02-27 17:34:05 +01:00
Daan De Meyer
8c0098d486 sbsign: Add support for offline signing
Add new options --prepare-offline-signing, --signed-data= and
--signed-data-signature= which allow for offline signing in a
similar manner to pesign.
2025-02-27 13:47:07 +01:00
Lennart Poettering
2f093d8364 man: follow our own naming rules more closely
In some examples we inserted "-initrd" after the "public-key" instead of
before when naming PEM files. Let's fix that, and stick to common
suffixes.
2025-02-27 10:08:50 +01:00
Lennart Poettering
da468d61ee man: follow our certificate/public-key/private-key PEM file naming rules
In 2cc58b6c8a and related we established
rules on naming certs/public-keys/private-keys:

*-public-key.pem
*-private-key.pem
*-certificate.pem

Let's follow that naming in repart's man page too.
2025-02-27 10:08:39 +01:00
Daan De Meyer
27e040f742 keyutil: Reword pkcs7 documentation string a little 2025-02-27 10:03:12 +01:00
Yu Watanabe
98fc082c31 man: fix typo
Follow-up for f8825c1364.
2025-02-27 13:37:20 +09:00
Daan De Meyer
461bd9277a meson: Add missing dbus_programs dependency on update-dbus-docs
All dbus programs have to be up-to-date for update-dbus-docs to
produce the expected output, so add the missing dependency.
2025-02-27 12:39:52 +09:00
Lennart Poettering
9a4f9e84c4 pam_systemd_home: tweak order in authentication stack
Let's move pam_systemd_home before pam_unix in the authentication hook.

Since a while we are exposing shadow entries for homed log entries via
NSS. This means that pam_unix now potentially has enough data for
authenticating a user on its own, without letting pam_systemd_home do
that. This is superficially OK, but also means that authentication will
always go via password, even if pkcs11/fido2 is registered.

Let's move this around, but be careful about it: let's list the precise
errors which we think are enough to terminating further PAM processing,
so that pam_unix comes into control in all cases where it's not clear
that pam_systemd_home owns the user record.

This previously wasn't visible to me, because on Fedora until authselect
1.5.1 (released earleir this year) the NSS shadow stuff was not enabled.

This does the same also for the "account" stack, except that the order
there already was as we want it.

Finally, shorten the account stack, by just requiring pam_unix.so and
dropping pam_permit.so, because it doesn't really serve much purpose
(and Fedora doesn't use it by default either.)
2025-02-26 18:12:08 +01:00
Lennart Poettering
14871a6529 efivars: kill SystemdOptions efi var support
This has been depracted since v254 (2023). Let's kill it for
good now, it has been long enough with 2y. Noone has shown up who wants
to keep it. And given it doesn't work in SB world anyway, and is not
measured is quite problematic security wise.
2025-02-26 17:28:43 +01:00
Mike Yuan
c578bf6e17 Expose chassis asset tag in hostnamed (#36487)
Closes #36442
2025-02-26 14:28:26 +01:00
Markus Kurz
2006e341d3 udev_device_has_tag: fix typo 2025-02-26 20:34:15 +09:00
Jelle van der Waa
7e638ccf59 hostnamed: expose ChassisAssetTag in dbus/varlink
Expose /sys/class/dmi/id/chassis_asset_tag in varlink/dbus commonly used
by companies to track inventory such as laptops.

On desktops and other products the `chassis_asset_tag` can contain
rubbish similar to product_name/product_vendor.

Closes: #36442
2025-02-26 11:29:25 +01:00
Lennart Poettering
810708f4b8 integritysetup: add remote-integritysetup.target to match remote-{crypt|verity}setup.target
Let's make the three subsystems more alike, and add remote-*setup.traget
for all three, enable them all three in the presets, and make them
behave in a similar fashion.
2025-02-25 21:40:05 +01:00
Dan Streetman
af69ea714d systemd-keyutil: add verb to conver PKCS#1 to PKCS#7
Add verb that takes a PKCS#1 signature (plain rsa) as input and a
certificates, and outputs a PKCS#7 binary detached signature (p7s),
which is what the kernel dm-verity driver expects.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2025-02-23 14:14:09 +00:00
Mike Yuan
c6cc7efcd3 sd-event: always operate on child source via pidfd
Follow-up for 6e14c46bac

Nowadays a pidfd is guarenteed to be around for child
event sources, hence drop the effectively unused pid-based
branches.

Addresses https://github.com/systemd/systemd/pull/36410#discussion_r1959930716
2025-02-21 18:08:55 +01:00
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