]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
8 months agodocs: Use mkosi -R instead of mkosi -t none 36528/head
Daan De Meyer [Wed, 26 Feb 2025 13:58:53 +0000 (14:58 +0100)] 
docs: Use mkosi -R instead of mkosi -t none

mkosi now supports -R to rerun build scripts without rebuilding the
image so let's document that instead of the current hack to prevent
the rebuild by changing the output format.

8 months agomkosi: Update to latest
Daan De Meyer [Wed, 26 Feb 2025 13:58:39 +0000 (14:58 +0100)] 
mkosi: Update to latest

8 months agocopy: Invoke hardlink context cleanup before restoring timestamps
Andreas Stührk [Tue, 25 Feb 2025 23:05:41 +0000 (00:05 +0100)] 
copy: Invoke hardlink context cleanup before restoring timestamps

When hardlink recreation is requested, it creates temporary files that
will be deleted once the context is destroyed. The deletion
(potentially) updates the directory's timestamps, so it's crucial that
the deletion happens before the directory timestamps are restored when
`COPY_RESTORE_DIRECTORY_TIMESTAMPS` is requested.

8 months agotimesync: several trivial cleanups (#36506)
Lennart Poettering [Wed, 26 Feb 2025 08:02:50 +0000 (09:02 +0100)] 
timesync: several trivial cleanups (#36506)

8 months agosd-bus: sort enumerated child objects (#36507)
Lennart Poettering [Wed, 26 Feb 2025 08:02:36 +0000 (09:02 +0100)] 
sd-bus: sort enumerated child objects (#36507)

Fixes #8008.

8 months agomake integritysetup/veritysetup more alike cryptsetup when it comes to remote operati...
Lennart Poettering [Tue, 25 Feb 2025 22:20:56 +0000 (23:20 +0100)] 
make integritysetup/veritysetup more alike cryptsetup when it comes to remote operation (#36501)

Let's address some asymmetries here.

8 months agosystemd-boot: some refactorings (#36510)
Lennart Poettering [Tue, 25 Feb 2025 22:20:34 +0000 (23:20 +0100)] 
systemd-boot: some refactorings (#36510)

Clean up systemd-boot a bit. Mostly makes handling of some menu entry
types less magic and more uniform. Doesn't really change behaviour in
any ways, except that we now condition things such as boot counting,
random seed management and entry selection saving carefully on the entry
type.

8 months agopackit: Switch to meson.version for the current version (#36509)
Luca Boccassi [Tue, 25 Feb 2025 21:07:56 +0000 (21:07 +0000)] 
packit: Switch to meson.version for the current version (#36509)

8 months agointegritysetup: add remote-integritysetup.target to match remote-{crypt|verity}setup... 36501/head
Lennart Poettering [Mon, 24 Feb 2025 10:32:00 +0000 (11:32 +0100)] 
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.

8 months agopreset: enable remote verity targets too
Lennart Poettering [Mon, 24 Feb 2025 09:51:37 +0000 (10:51 +0100)] 
preset: enable remote verity targets too

Let's make cryptsetup and veritysetup more symmetric, and enable the
remote target for the latter the same way we enable the remote target
for the former by default.

8 months agoboot: split out call that adds reboot/poweroff/firmware entries 36510/head
Lennart Poettering [Tue, 25 Feb 2025 11:43:11 +0000 (12:43 +0100)] 
boot: split out call that adds reboot/poweroff/firmware entries

8 months agoboot: make secure boot enrollment less special
Lennart Poettering [Tue, 25 Feb 2025 11:40:43 +0000 (12:40 +0100)] 
boot: make secure boot enrollment less special

This is the last entry type that has special handling: with this in
place we now always invoke entry handlers the very same way. via the
.call() method of the BootEntry structure.

8 months agoboot: move check if secure boot enrollment applies to a single place
Lennart Poettering [Tue, 25 Feb 2025 11:36:17 +0000 (12:36 +0100)] 
boot: move check if secure boot enrollment applies to a single place

Let's check if sb enrollment applies at a single place: inside the
discovery function, and let's not bother with additional checks later.

8 months agoboot: make regular entries less special
Lennart Poettering [Tue, 25 Feb 2025 11:35:25 +0000 (12:35 +0100)] 
boot: make regular entries less special

Let's try to always invoke entries via the call() method of BootEntry
objects, to stick to a single uniform way to do so.

8 months agoboot: only save entry for some entry types
Lennart Poettering [Tue, 25 Feb 2025 11:34:49 +0000 (12:34 +0100)] 
boot: only save entry for some entry types

Much like the previous one, let's also condition the entry selection
saving on entry types.

8 months agoboot: only do random seed management for some entry types
Lennart Poettering [Tue, 25 Feb 2025 11:19:48 +0000 (12:19 +0100)] 
boot: only do random seed management for some entry types

Similar to the previous commits, let's carefully condition random seed
management (which might be slow, and simply pointless for various entry
types) on the entry type.

8 months agoboot: only do boot counting management for some menu entries
Lennart Poettering [Tue, 25 Feb 2025 11:16:10 +0000 (12:16 +0100)] 
boot: only do boot counting management for some menu entries

Let's do boot counting only for some menu entry types, and carefully
list which types those are.

8 months agoboot: make .call() method of BootEntry more complete
Lennart Poettering [Tue, 25 Feb 2025 11:12:56 +0000 (12:12 +0100)] 
boot: make .call() method of BootEntry more complete

Let's pass some context information to the .call() methods so that it's
sufficient to implement the handlers for all entry types with them.

(This commit doesn't port the various entry types over though, that
happens in later commits.)

8 months agoboot: split out line editor
Lennart Poettering [Tue, 25 Feb 2025 10:55:19 +0000 (11:55 +0100)] 
boot: split out line editor

let's make this beast of boot.c a bit more digestable

8 months agopackit: Switch to meson.version for the current version 36509/head
Daan De Meyer [Tue, 25 Feb 2025 11:01:53 +0000 (12:01 +0100)] 
packit: Switch to meson.version for the current version

8 months agomkosi: update fedora commit reference
Daan De Meyer [Tue, 25 Feb 2025 18:30:42 +0000 (19:30 +0100)] 
mkosi: update fedora commit reference

9b6884d2e1 Stop using version_no_tilde for github archives
5671cf6132 List the fallback Source0 first

8 months agomeson: add more space for sections
Lennart Poettering [Tue, 25 Feb 2025 10:54:41 +0000 (11:54 +0100)] 
meson: add more space for sections

I ran into the limit with ParticleOS, with 6 profiles, hence I think the
current default value is a bit low. let's bump it 4x, to 120. This is
still a lot lower than 500 or so which Debian uses downstream.

We can look into raising this further should we collide with this again,
but for now, let's try 120 and see how it goes in practice.

8 months agotest-bus-object: check if enumerated objects are sorted 36507/head
Yu Watanabe [Tue, 25 Feb 2025 14:40:45 +0000 (23:40 +0900)] 
test-bus-object: check if enumerated objects are sorted

8 months agosd-bus: sort enumerated child objects
Yu Watanabe [Tue, 25 Feb 2025 05:57:39 +0000 (14:57 +0900)] 
sd-bus: sort enumerated child objects

Fixes #8008.

8 months agoupdate TODO
Lennart Poettering [Tue, 25 Feb 2025 10:54:23 +0000 (11:54 +0100)] 
update TODO

8 months agomkosi: Enable History= option (#36500)
Daan De Meyer [Tue, 25 Feb 2025 11:44:41 +0000 (12:44 +0100)] 
mkosi: Enable History= option (#36500)

This option makes mkosi "remember" all the CLI options specified on the
command line when building an image. This means they don't need to be
specified again when booting the image afterwards or doing any other
operation on the image with "mkosi xxx".

As an example of how this is useful, currently, when running "mkosi -d
opensuse -f" to build an opensuse image and then running "mkosi sandbox
-- meson test -C build TEST-86-MULTI-UKI-PROFILE", running the test will
try to add virtiofs mounts of the fedora~rawhide build directory on my
machine instead of the opensuse one. With the History= option enabled,
it will use the opensuse tumbleweed directory as expected.

8 months agomkosi: Enable History= option 36500/head
Daan De Meyer [Mon, 24 Feb 2025 09:56:26 +0000 (10:56 +0100)] 
mkosi: Enable History= option

This option makes mkosi "remember" all the CLI options specified on
the command line when building an image. This means they don't need
to be specified again when booting the image afterwards or doing any
other operation on the image with "mkosi xxx".

As an example of how this is useful, currently, when running "mkosi
-d opensuse -f" to build an opensuse image and then running "mkosi
sandbox -- meson test -C build TEST-86-MULTI-UKI-PROFILE", running
the test will try to add virtiofs mounts of the fedora~rawhide build
directory on my machine instead of the opensuse one. With the History=
option enabled, it will use the opensuse tumbleweed directory as expected.

We stop setting --extra-search-path and --output-dir in the integration test
wrapper as these are settings that are "remembered" by enabling the History=
option.

8 months agotest: Do not add integration tests if want_tests == 'false'
Daan De Meyer [Tue, 25 Feb 2025 09:59:20 +0000 (10:59 +0100)] 
test: Do not add integration tests if want_tests == 'false'

8 months agobootctl-install: Use i2d_PKCS7() instead of i2d_PKCS7_SIGNED()
Daan De Meyer [Tue, 25 Feb 2025 07:32:33 +0000 (08:32 +0100)] 
bootctl-install: Use i2d_PKCS7() instead of i2d_PKCS7_SIGNED()

For a detached signature, these are equivalent so let's use i2d_PKCS7()
like we do everywhere else.

8 months agoTEST-64-UDEV-STORAGE: Stop using mkosi configure scripts
Daan De Meyer [Mon, 24 Feb 2025 16:14:01 +0000 (17:14 +0100)] 
TEST-64-UDEV-STORAGE: Stop using mkosi configure scripts

Now that we have mkosi sandbox, meson runs with the mkosi tools tree
mounted (if one is used at all), so we can implement all the qemu feature
checks in meson itself, removing the need for mkosi configure scripts.

8 months agoTEST-53-ISSUE-16347: Implement rtc via custom argument
Daan De Meyer [Mon, 24 Feb 2025 16:12:22 +0000 (17:12 +0100)] 
TEST-53-ISSUE-16347: Implement rtc via custom argument

Let's get rid of the configure script for this use case by just
implementing the necessary logic in integration-test-wrapper.py.
We need to get rid of our usage of configure scripts to allow enabling
the History= setting.

8 months agomkosi: Update to latest
Daan De Meyer [Mon, 24 Feb 2025 21:24:52 +0000 (22:24 +0100)] 
mkosi: Update to latest

8 months agotimesync: add short comment for boolean argument 36506/head
Yu Watanabe [Tue, 25 Feb 2025 04:45:07 +0000 (13:45 +0900)] 
timesync: add short comment for boolean argument

8 months agotimesync: drop meaningless boolean flag
Yu Watanabe [Tue, 25 Feb 2025 04:39:43 +0000 (13:39 +0900)] 
timesync: drop meaningless boolean flag

The boolean flag is always true, as manager_save_time_and_rearm() is
called unconditionally.

Follow-up for 33e82f3ef33a2497f9838a5fbb924c7501d8dd9e.

8 months agotimesync: use event_reset_time_relative()
Yu Watanabe [Tue, 25 Feb 2025 04:00:56 +0000 (13:00 +0900)] 
timesync: use event_reset_time_relative()

No functional change, just refactoring.

8 months agofuzz: decompress_startswith() may return zero (#36490)
Yu Watanabe [Tue, 25 Feb 2025 02:05:06 +0000 (11:05 +0900)] 
fuzz: decompress_startswith() may return zero (#36490)

Also, disables fuzz-compress on oss-fuzz.
Fixes #36472.

8 months agorepart: when using erofs and log level is not debug, use --quiet
Luca Boccassi [Sun, 23 Feb 2025 19:05:24 +0000 (19:05 +0000)] 
repart: when using erofs and log level is not debug, use --quiet

mkfs.erofs is extremely verbose and will log every single file added
to the filesystem, which is a lot of them when building a rootfs.

8 months agosystemd-keyutil: add verb to conver PKCS#1 to PKCS#7
Dan Streetman [Fri, 21 Feb 2025 09:36:53 +0000 (09:36 +0000)] 
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>
8 months agofstab-util: port use of setmntent() and friends to libmount (#36489)
Daan De Meyer [Sun, 23 Feb 2025 11:21:19 +0000 (12:21 +0100)] 
fstab-util: port use of setmntent() and friends to libmount (#36489)

8 months agosd-event: pidfdize sd_event_source_send_child_signal()
Mike Yuan [Sat, 22 Feb 2025 23:29:44 +0000 (00:29 +0100)] 
sd-event: pidfdize sd_event_source_send_child_signal()

Follow-up for c6cc7efcd35f729cf0db8f8502752c7d83a0be95

The documentation has been updated, but apparently I forgot
to update the function itself...

Also, actually pass flags to pidfd_send_signal(). Previously
it was spuriously ignored.

8 months agofuzz: tentatively disable fuzz-compress on oss-fuzz 36490/head
Yu Watanabe [Sat, 22 Feb 2025 20:34:55 +0000 (05:34 +0900)] 
fuzz: tentatively disable fuzz-compress on oss-fuzz

It does not work on oss-fuzz for some reasons. See #11018.

8 months agofuzz: decompress_startswith() may return zero
Yu Watanabe [Sat, 22 Feb 2025 19:59:46 +0000 (04:59 +0900)] 
fuzz: decompress_startswith() may return zero

Fixes #36472.

8 months agosd-event: always operate on child source via pidfd (#36480)
Yu Watanabe [Sat, 22 Feb 2025 19:41:28 +0000 (04:41 +0900)] 
sd-event: always operate on child source via pidfd (#36480)

8 months agofstab-util: port use of setmntent() and friends to libmount 36489/head
Mike Yuan [Wed, 5 Feb 2025 13:19:27 +0000 (14:19 +0100)] 
fstab-util: port use of setmntent() and friends to libmount

8 months agolibmount-util: introduce libmount_parse_fstab() wrapper
Mike Yuan [Mon, 3 Feb 2025 15:46:51 +0000 (16:46 +0100)] 
libmount-util: introduce libmount_parse_fstab() wrapper

8 months agofstab-util: join 'filtered' only if requested by caller
Mike Yuan [Sat, 15 Feb 2025 17:26:04 +0000 (18:26 +0100)] 
fstab-util: join 'filtered' only if requested by caller

8 months agosbsign: Don't set bit in SpcPeImageData->flags
Daan De Meyer [Fri, 21 Feb 2025 21:41:26 +0000 (22:41 +0100)] 
sbsign: Don't set bit in SpcPeImageData->flags

Neither sbsign nor pesign set this flag in SpcPeImageData->flags,
which is about which resources should be included specifying "Which
portions of the Windows PE file are hashed." according to the
authenticode spec. However, this is followed by "Although flags is
always present, it is ignored when calculating the file hash for both
signing and verification purposes". So as it doesn't seem to do
anything useful and the other tools don't set any of these flags
either, let's follow suite and not set this flag ourselves either.

8 months agohwdb: add axis range corrections for the Lenovo Yoga Slim 7 14ARE05
KidGrimes [Fri, 21 Feb 2025 21:27:53 +0000 (18:27 -0300)] 
hwdb: add axis range corrections for the Lenovo Yoga Slim 7 14ARE05

8 months agomkosi: add libapparmor1 to package list for opensuse
Luca Boccassi [Fri, 21 Feb 2025 21:32:27 +0000 (21:32 +0000)] 
mkosi: add libapparmor1 to package list for opensuse

TEST-02-UNITTESTS.sh[4381]: [ 2329.636166] test-dlopen-so[650]: libapparmor.so.1 is not installed: libapparmor.so.1: cannot open shared object file: No such file or directory
TEST-02-UNITTESTS.sh[4381]: [ 2329.636174] test-dlopen-so[650]: Assertion 'dlopen_libapparmor() >= 0' failed at src/test/test-dlopen-so.c:103, function run(). Aborting.

Follow-up for 384949f7dee164c2c3cfd78f94a5f27b61fb7c28

8 months agoCoding style followups (#36476)
Luca Boccassi [Fri, 21 Feb 2025 21:58:54 +0000 (21:58 +0000)] 
Coding style followups (#36476)

8 months agoprocess-util: refuse FORK_WAIT + FORK_FREEZE combination
Mike Yuan [Thu, 20 Feb 2025 19:51:05 +0000 (20:51 +0100)] 
process-util: refuse FORK_WAIT + FORK_FREEZE combination

8 months agosd-event: always operate on child source via pidfd 36480/head
Mike Yuan [Tue, 18 Feb 2025 15:49:05 +0000 (16:49 +0100)] 
sd-event: always operate on child source via pidfd

Follow-up for 6e14c46bac760d01868b0bf48461f6ac44c86be3

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

8 months agosd-event: assert on hashmap_remove(child.pid)
Mike Yuan [Fri, 21 Feb 2025 15:45:34 +0000 (16:45 +0100)] 
sd-event: assert on hashmap_remove(child.pid)

Follow-up for 54988a27b9d1487e1690f94b79031ef61edd6651
and a342c71d360e083b3f6b06a64d852c4e3aceeef3

8 months agoprocess-util: introduce SIGINFO_CODE_IS_DEAD helper
Mike Yuan [Tue, 18 Feb 2025 16:06:19 +0000 (17:06 +0100)] 
process-util: introduce SIGINFO_CODE_IS_DEAD helper

8 months agodocs/CONTROL_GROUP_INTERFACE: fix typo
Lin Jian [Fri, 21 Feb 2025 13:07:27 +0000 (21:07 +0800)] 
docs/CONTROL_GROUP_INTERFACE: fix typo

8 months agoudev-builtin-blkid: merge var definitions, fix grammar 36476/head
Mike Yuan [Fri, 21 Feb 2025 13:17:57 +0000 (14:17 +0100)] 
udev-builtin-blkid: merge var definitions, fix grammar

Follow-up for f8825c1364fb1c3f3f5d96654e779fd51500f476

8 months agobasic/utf8: add missing assertion
Mike Yuan [Tue, 18 Feb 2025 13:33:01 +0000 (14:33 +0100)] 
basic/utf8: add missing assertion

Follow-up for 104a6b8c390730f66f5acbcaefbc27898bfef9fe

8 months agobasic/strv: minor coding style follow-ups
Mike Yuan [Tue, 18 Feb 2025 13:32:30 +0000 (14:32 +0100)] 
basic/strv: minor coding style follow-ups

Follow-up for 428146dc89506725f777ae82d288439340926a83

Addresses https://github.com/systemd/systemd/pull/36271#discussion_r1958334800

8 months agocore: dlopen()'ify libapparmor
Mike Yuan [Sun, 7 Jul 2024 17:35:40 +0000 (19:35 +0200)] 
core: dlopen()'ify libapparmor

In Arch Linux we currently have a half-baked apparmor support,
in particular we cannot link systemd to libapparmor for service
context integration, since that will pull apparmor into base system.
Hence, let's turn this into a dlopen dep.

Ref: https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/issues/22

8 months agoSupport booting from rootfs acquired via HTTP (#36314)
Lennart Poettering [Fri, 21 Feb 2025 10:26:14 +0000 (11:26 +0100)] 
Support booting from rootfs acquired via HTTP (#36314)

This extends systemd-import-generator to not only download a disk image
at boot, but also attach it to a loopback device, so that we can boot
from it.

We have most of the pieces already in place, this just polishes some
things, to make this round.

The topmost commit contains example command lines that just work to make
`systemd-vmspawn` boot from a `mkosi serve` call.

Note that this does not address how to get the UKI running on the target
system, this only deals with the later boot phase once the UKI is
already running.

This is WIP, because it lacks docs, and I want to do some more
polishing. But it works great.

Ultimate goal, provide a complete solution so that we also can do uefi
http boot for ukis

8 months agoupdate TODO 36314/head
Lennart Poettering [Mon, 10 Feb 2025 12:18:25 +0000 (13:18 +0100)] 
update TODO

8 months agoboot: when we detect that sd-boot is called as NBP, print friendly message
Lennart Poettering [Wed, 12 Feb 2025 21:42:10 +0000 (22:42 +0100)] 
boot: when we detect that sd-boot is called as NBP, print friendly message

Fixes: #11850
8 months agosd-boot: also read type #1 entries from SMBIOS Type #11
Lennart Poettering [Wed, 12 Feb 2025 08:31:29 +0000 (09:31 +0100)] 
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.

8 months agovmspawn: simplify cmdline_add_vsock() a tiny bit
Lennart Poettering [Wed, 12 Feb 2025 08:32:49 +0000 (09:32 +0100)] 
vmspawn: simplify cmdline_add_vsock() a tiny bit

8 months agovmspawn: add --smbios11= switch for passing arbitrary smbios type #11 strings to vm
Lennart Poettering [Wed, 12 Feb 2025 08:32:18 +0000 (09:32 +0100)] 
vmspawn: add --smbios11= switch for passing arbitrary smbios type #11 strings to vm

8 months agovmspawn: split out code that appends kernel command line into its own helper
Lennart Poettering [Wed, 12 Feb 2025 08:27:17 +0000 (09:27 +0100)] 
vmspawn: split out code that appends kernel command line into its own helper

8 months agoboot: add new 'uki-url' bls type #1 menu items for booting remote UKIs
Lennart Poettering [Tue, 11 Feb 2025 08:34:20 +0000 (09:34 +0100)] 
boot: add new 'uki-url' bls type #1 menu items for booting remote UKIs

Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135

8 months agoboot: add new bls type #1 stanza "uki"
Lennart Poettering [Tue, 11 Feb 2025 08:18:14 +0000 (09:18 +0100)] 
boot: add new bls type #1 stanza "uki"

This one is between "efi" and "linux": we'll recognize such entries as
linux, but we'll just invoke them as EFI binaries.

This creates a high-level concept for invoking UKIs via indirection of a
bls type #1 entry, for example to permit invocation from a non-standard
path or for giving entries a different name.

Companion BLS spec PR:

https://github.com/uapi-group/specifications/pull/135

(Let's rename LOADER_UNIFIED_LINUX to LOADER_TYPE2_UKI at the same time
to reduce confusion what is what)

8 months agoboot: move behaviour checks into per-entry-type helpers
Lennart Poettering [Tue, 11 Feb 2025 06:35:02 +0000 (07:35 +0100)] 
boot: move behaviour checks into per-entry-type helpers

8 months agoboot: be stricter when filtering out invalid bls #1 entries
Lennart Poettering [Tue, 11 Feb 2025 06:33:34 +0000 (07:33 +0100)] 
boot: be stricter when filtering out invalid bls #1 entries

8 months agoboot: bls type #1 with 'efi' stanza are bls type #1 too
Lennart Poettering [Tue, 11 Feb 2025 06:32:47 +0000 (07:32 +0100)] 
boot: bls type #1 with 'efi' stanza are bls type #1 too

8 months agoefi: add strcspn16()/strspn16() to efi libs too
Lennart Poettering [Tue, 11 Feb 2025 22:47:00 +0000 (23:47 +0100)] 
efi: add strcspn16()/strspn16() to efi libs too

8 months agoefi-string: add new xstr16_to_ascii() helper
Lennart Poettering [Tue, 11 Feb 2025 18:22:28 +0000 (19:22 +0100)] 
efi-string: add new xstr16_to_ascii() helper

8 months agoefi: modernize reconnect_all_drivers() a bit
Lennart Poettering [Tue, 11 Feb 2025 18:22:09 +0000 (19:22 +0100)] 
efi: modernize reconnect_all_drivers() a bit

8 months agogpt-auto-generator: if root=gpt-auto is specified on kernel cmdline, always wait...
Lennart Poettering [Mon, 10 Feb 2025 22:15:15 +0000 (23:15 +0100)] 
gpt-auto-generator: if root=gpt-auto is specified on kernel cmdline, always wait for /dev/gpt-auto-root symlink

So far our login in gpt-auto-generator when run in the initrd has been
to generate the units that wait for /dev/gpt-auto-root to show up and
mount them only if we have the loader partition EFI variables set. This
is of course not the case for network boots with a UKI kernel, which
means auto-gpt would not work for mounting the rootfs.

What's nasty is that we don't know for sure whether the "rootdisk"
loopback device will shown up eventually, as it needs explicit
configuration by the user via the kernel cmdline, or could be configured
entirely indepdenently. Hence, let's tweak the logic when we wat for
/dev/gpt-auto-root as device to mount: make the gpt auto root logic a
tristate: if root=gpt-auto is specified on the cmdline *definitely*
enable the logic. If root= is specified and set to anyting else,
*definitely* disable the logic. And if root= is not specified check for
the EFI partition vars – as before – to conditionalized things.

Or in other words, you can now boot the same image either via ESP/local
boot or via netboot with a kernelcmdline image like this:

    rd.systemd.pull=verify=no,machine,blockdev,bootorigin,raw:rootdisk:image.raw root=gpt-auto rootflags=x-systemd.device-timeout=infinity ip=any

8 months agoudev-builtin-blkid: use loopback block device 'ref' field fo determining gpt-auto...
Lennart Poettering [Mon, 10 Feb 2025 21:24:52 +0000 (22:24 +0100)] 
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.

8 months agoimport-generator: give import services better names
Lennart Poettering [Fri, 7 Feb 2025 17:22:13 +0000 (18:22 +0100)] 
import-generator: give import services better names

Previously, we'd name the import services numerically. Let's instead use
the local target file name, i.e. the object we are creating with these
services locally. That's useful so that we can robustely order against
these service instances, should we need to one day.

8 months agofstab-generator: validate root= and mount.usr= the same way
Lennart Poettering [Mon, 10 Feb 2025 12:12:46 +0000 (13:12 +0100)] 
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.

8 months agofstab-generator: support creating bind mounts via root= kernel cmdline switches
Lennart Poettering [Mon, 10 Feb 2025 11:56:08 +0000 (12:56 +0100)] 
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.

8 months agoimport-generator: optionally import images into /run/ hierarchy rather than /var/
Lennart Poettering [Mon, 10 Feb 2025 10:57:19 +0000 (11:57 +0100)] 
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.

8 months agoimportd: optionally allow clients to specify alternative image root
Lennart Poettering [Mon, 10 Feb 2025 10:52:21 +0000 (11:52 +0100)] 
importd: optionally allow clients to specify alternative image root

8 months agoimport-generator: add new option 'bootorigin' to derive URL from efi boot url
Lennart Poettering [Sun, 9 Feb 2025 23:23:21 +0000 (00:23 +0100)] 
import-generator: add new option 'bootorigin' to derive URL from efi boot url

8 months agosd-stub: if we are http booted, query source URL and write to EFI variable
Lennart Poettering [Fri, 7 Feb 2025 22:30:13 +0000 (23:30 +0100)] 
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.

8 months agoimport-generator: optionally create loopback devices after download
Lennart Poettering [Fri, 7 Feb 2025 15:29:00 +0000 (16:29 +0100)] 
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.

8 months agoman: mention 'rd.' prefix for import-generator kernel cmdline options
Lennart Poettering [Thu, 13 Feb 2025 09:37:11 +0000 (10:37 +0100)] 
man: mention 'rd.' prefix for import-generator kernel cmdline options

8 months agounits: add generic service for attaching a file to a loopback device
Lennart Poettering [Fri, 7 Feb 2025 15:33:17 +0000 (16:33 +0100)] 
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.

8 months agodissect: add --quiet mode
Lennart Poettering [Fri, 7 Feb 2025 18:44:13 +0000 (19:44 +0100)] 
dissect: add --quiet mode

8 months agodissect: optionally derive loop-ref from image filename
Lennart Poettering [Fri, 7 Feb 2025 16:55:08 +0000 (17:55 +0100)] 
dissect: optionally derive loop-ref from image filename

8 months agomkosi: add kernel-bootcfg to all images
Lennart Poettering [Sun, 9 Feb 2025 06:28:44 +0000 (07:28 +0100)] 
mkosi: add kernel-bootcfg to all images

kernel-bootcfg --add-uri= is just too useful when playing with network
boot. Let's just add it to our images.

8 months agomkosi: include networkd + import-generator in initrd
Lennart Poettering [Fri, 7 Feb 2025 16:54:36 +0000 (17:54 +0100)] 
mkosi: include networkd + import-generator in initrd

8 months agoexec-invoke: Use FORK_DETACH when forking off pid namespace child (#36446)
Luca Boccassi [Fri, 21 Feb 2025 00:27:17 +0000 (00:27 +0000)] 
exec-invoke: Use FORK_DETACH when forking off pid namespace child (#36446)

This ensures the child process is immediately re-parented to the
manager process which avoids a "Supervising process xxx which is
not our child. We'll most likely not notice when it exits." warning
which can currently happen if the parent systemd-executor parent
process sends the pid namespace child process pidref to the manager
process and the manager process dispatches the child process pidref
before the systemd-executor parent process exits, since at that point
the pid namespace child process's parent will still be the
systemd-executor parent process and not the manager process.

8 months agoexec-invoke: Use FORK_DETACH when forking off pid namespace child 36446/head
Daan De Meyer [Wed, 19 Feb 2025 19:57:24 +0000 (20:57 +0100)] 
exec-invoke: Use FORK_DETACH when forking off pid namespace child

This ensures the child process is immediately re-parented to the
manager process which avoids a "Supervising process xxx which is
not our child. We'll most likely not notice when it exits." warning
which can currently happen if the parent systemd-executor parent
process sends the pid namespace child process pidref to the manager
process and the manager process dispatches the child process pidref
before the systemd-executor parent process exits, since at that point
the pid namespace child process's parent will still be the
systemd-executor parent process and not the manager process.

8 months agoprocess-util: Allow setting ret_pid with FORK_DETACH in safe_fork()
Daan De Meyer [Wed, 19 Feb 2025 19:38:14 +0000 (20:38 +0100)] 
process-util: Allow setting ret_pid with FORK_DETACH in safe_fork()

Let's allow getting the pid even if the caller sets FORK_DETACH. We
do this via a socketpair() over which we send the inner child pid.

8 months agoSome minor improvements to D-Bus docs (#36467)
Lennart Poettering [Thu, 20 Feb 2025 19:48:55 +0000 (20:48 +0100)] 
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

8 months agoprocess-util: Implement safe_fork_full() on top of pidref_safe_fork_full()
Daan De Meyer [Thu, 20 Feb 2025 08:24:58 +0000 (09:24 +0100)] 
process-util: Implement safe_fork_full() on top of pidref_safe_fork_full()

Let's switch things around, and move the internals of safe_fork_full() into
pidref_safe_fork_full() and make safe_fork_full() a trivial wrapper on top
of pidref_safe_fork_full().

8 months agotest-async: Use ASSERT_OK_ERRNO() instead of ASSERT_OK() where applicable
Daan De Meyer [Thu, 20 Feb 2025 10:14:13 +0000 (11:14 +0100)] 
test-async: Use ASSERT_OK_ERRNO() instead of ASSERT_OK() where applicable

8 months agotest-async: Specify FORK_REOPEN_LOG in one more place
Daan De Meyer [Thu, 20 Feb 2025 10:13:51 +0000 (11:13 +0100)] 
test-async: Specify FORK_REOPEN_LOG in one more place

Otherwise debugging assertions from the child process is rather hard.

8 months agoFix race in io.systemd.Machine.Open() test case (#36410)
Daan De Meyer [Thu, 20 Feb 2025 18:53:00 +0000 (19:53 +0100)] 
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.

8 months agodocs: Clarify that login1 signals are not emitted for convenience objects 36467/head
Philip Withnall [Thu, 20 Feb 2025 18:15:43 +0000 (18:15 +0000)] 
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>
8 months agodocs: Fix some confusing wording in various D-Bus docs
Philip Withnall [Thu, 20 Feb 2025 18:13:00 +0000 (18:13 +0000)] 
docs: Fix some confusing wording in various D-Bus docs

Signed-off-by: Philip Withnall <pwithnall@gnome.org>