Daan De Meyer [Sun, 17 Mar 2024 08:47:54 +0000 (09:47 +0100)]
qemu: Set vmm.notify_socket credential even if SMBIOS is not supported
Let's apply the same credential passing logic to vmm.notify_socket that
we apply to all other credentials. Use SMBIOS if available and fall back
to fw_cfg and kernel command line otherwise.
Daan De Meyer [Sat, 16 Mar 2024 19:04:36 +0000 (20:04 +0100)]
Remove vmspawn verb in favor of VirtualMachineMonitor= setting
Instead of adding a new verb for each new virtual machine monitor we
want to support, let's configure the vmm to use with a new setting. As
vmspawn is still experimental we don't need to keep backwards compat
intact in this case.
Daan De Meyer [Fri, 15 Mar 2024 16:13:45 +0000 (17:13 +0100)]
Fix kernel module glob
When dkms modules are installed there will be .ko modules in directories
other than "kernel" so make sure we only look for modules in the "kernel"
directory.
Daan De Meyer [Fri, 15 Mar 2024 12:09:39 +0000 (13:09 +0100)]
Always mount context.root to /buildroot
Let's leak fewer host specific details into the sandbox by always
mounting the image root directory to /buildroot in the sandbox. This
also simplifies debugging as the image rootfs will always be at /rootfs
instead of in some host specific path.
Daan De Meyer [Fri, 15 Mar 2024 16:11:12 +0000 (17:11 +0100)]
Force virtiofsd to use inode-handles when running as root
When running as root virtiofsd should have all it needs to use
file handles which reduces the chance of running out of file descriptors,
so make sure it uses them when running as root.
Daan De Meyer [Fri, 15 Mar 2024 13:41:12 +0000 (14:41 +0100)]
Enable --cache=always for virtiofsd
According to the documentation, this can be enabled when virtiofsd
has exclusive access to the directory, which is the case for us so
let's enable this.
Daan De Meyer [Fri, 15 Mar 2024 10:57:14 +0000 (11:57 +0100)]
Filter and sort all mounts in sandbox_cmd()
We don't want users of sandbox_cmd() to have to care about mount
ordering. Currently, if mounts with a more general destination are
ordered after mounts with a more specific destination, the earlier
mount is hidden by the later mount. By sorting by destination, we
avoid this issue.
Richard Maw [Wed, 13 Mar 2024 17:30:34 +0000 (17:30 +0000)]
Restore all of a user's groups when running sync
Shared development hardware often has storage partitioned up by project
groups, with the root of the shared storage owned by root:project.
Since this group isn't the primary group of the user
using setgroups and restoring groups to just the user's primary gid
will mean that it does not have this project group gid
and so won't be able to see the contents of this shared directory.
Using getgrouplist to get all of the groups from the user database
allows these additional groups to be set.
Richard Maw [Wed, 13 Mar 2024 17:17:39 +0000 (17:17 +0000)]
Reorder ExtraSearchPaths mounts before options
When not running in a tools tree the extra search paths are
read-only bind-mounted into the sandbox.
Files are initially created in the workspace tree but then moved
into the output directory after they are complete.
If the directories are on different devices the rename syscall
falls back to a copy then delete.
It is not unusual to have a single build output directory
and you might potentially want your mkosi output directory in there.
If you are adding ExtraSearchPaths to use just-built executables
then this probably points to your `build/` directory.
If search paths are bind-mounted in read-only after the copy command's
sandboxing options, then this generates a command-line with options:
`--bind build/mkosi.output build/mkosi.output ... --bind-ro build build`
which means that the output directory is not writable.
Ordering the sandbox's own mount arguments before the command's options
should ensure the read-only search paths mount doesn't inferfere with
the command's writable bind-mounts.
Daan De Meyer [Thu, 14 Mar 2024 13:54:45 +0000 (14:54 +0100)]
Introduce flock_or_die() and use it in various places
Let's avoid weird error cases caused by two instances of mkosi trying
to currently do stuff with the same output by taking a BSD lock when
trying to do something with the output.
Jörg Behrmann [Tue, 12 Mar 2024 16:56:27 +0000 (17:56 +0100)]
arch: install dbus-broker and dbus-broker-units explicitly
dbus and dbus-units have been split in Arch recently. Currently everything
seems to be pulled in CI, let's see whether we can get this down to just
dbus-broker.
Daan De Meyer [Wed, 13 Mar 2024 22:51:11 +0000 (23:51 +0100)]
ci: Btrfs mount option tuning
Let's choose the lowest compression level so as to not impact CPU
usage too much. Use noatime as it's generally a straight speed boost
and make sure some new btrfs features are enabled (should already
be enabled but never hurts to be sure).
Daan De Meyer [Wed, 13 Mar 2024 16:20:19 +0000 (17:20 +0100)]
ci: Do all work on a btrfs filesystem
Let's make sure we take advantage of our COW and subvolume support
in CI by doing all work in a btrfs filesystem. Additionally enable
compression and user subvolume deletes on the btrfs filesystem to
speed things up even more.
Daan De Meyer [Wed, 13 Mar 2024 21:05:24 +0000 (22:05 +0100)]
Always create directories as invoking user if not invoked as root
We don't want to leak the subuids into the system, so make sure any
directories created by INVOKING_USER.mkdir() are always created as
the invoking user if we're not invoked as root.
Daan De Meyer [Wed, 13 Mar 2024 16:18:50 +0000 (17:18 +0100)]
Optimize rmtree() for btrfs subvolumes
Try "btrfs subvolume delete" on subvolumes and fall back to a regular
delete since it will fail for unprivileged users without the
user_subvol_rm_allowed mount option.
Daan De Meyer [Wed, 13 Mar 2024 13:16:17 +0000 (14:16 +0100)]
ci: Enable KVM
Since https://github.blog/2024-01-17-github-hosted-runners-double-the-power-for-open-source/,
it seems that KVM has started working, so let's make sure we take
advantage of it to speed up CI.
Daan De Meyer [Wed, 13 Mar 2024 08:43:08 +0000 (09:43 +0100)]
Run sync scripts in strict sandbox again
We can't use a relaxed sandbox as we need to be able to mount the
directories containing certificates and keys from the tools tree
(finalize_crypto_mounts()) which will fail with permission errors
in a relaxed sandbox if the required mountpoints do not already
exist in the host filesystem.
So let's switch back to a strict sandbox, except that we now always
run as root in the strict sandbox so the overlay mount for /usr from
the package manager tree won't fail anymore.
Daan De Meyer [Mon, 11 Mar 2024 13:57:58 +0000 (14:57 +0100)]
Rework QemuFirmware=
- Use the qemu official firmware descriptions to look up OVMF
firmware instead of having our own homegrown logic.
- Add QemuFirmware=uefi-secure-boot to explicitly look for firmware
with secure boot support
- Add QemuFirmwareVariables=microsoft to use OVMF variables with
Microsoft keys enrolled
- Add QemuFirmwareVariables=custom to enroll the certificate from
SecureBootCertificate= into the OVMF variables
This commit also contains the changes from a second commit that
was accidentally rebased into this one:
Only use already signed binaries when ShimBootloader=signed
When we're using signed shim, we need to make sure we use already
signed bootloaders, kernel images and UKIs. Anything we sign ourselves
will cause security violations in shim.
Daan De Meyer [Tue, 12 Mar 2024 20:05:50 +0000 (20:05 +0000)]
Check for TERM=unknown and set TERM=dumb if not on tty
in CI, TERM is set to "unknown" so let's check for that and translate
it to "dumb" if we're not on a tty which systemd checks for when it
decides whether to enable logging or not. Also set TERM itself on
the kernel command line which is another thing parsed by systemd to check
whether to log colors or not. Finally, make sure we set "TERM" correctly
in our own environment that is passed to scripts
Daan De Meyer [Tue, 12 Mar 2024 16:41:51 +0000 (16:41 +0000)]
Disable SELinux relabeling by default for default image
Sometimes selinux-policy gets pulled in as a dependency, causing
SELinux relabels even though we don't care about SELinux at all in
the general case, so let's by default not relabel anything.
Daan De Meyer [Tue, 12 Mar 2024 16:12:06 +0000 (16:12 +0000)]
Streamline test logging
Let's get rid of the status messages in favor of logging the journal
itself to the console. Let's also make sure we get info messages on
the console from the journal. Finally, make the kernel log at INFO
level instead of the default WARNING.
Daan De Meyer [Mon, 11 Mar 2024 11:22:09 +0000 (12:22 +0100)]
Run sync scripts in relaxed sandbox without package manager trees
Sync scripts run as the invoking user in the sandbox, which means
that they're not able to mount an overlayfs over /usr in the sandbox
to overlay extra files from package manager trees.
To circumvent the issue, let's run sync scripts in a relaxed sandbox
without package manager trees, which shouldn't be crucial to have
when running sync scripts.
Daan De Meyer [Mon, 11 Mar 2024 11:18:01 +0000 (12:18 +0100)]
Always run as root in Context sandbox
If there's files in /usr in the package manager tree, we need to
be running as root to mount an overlayfs on top of /usr so make
sure we are always root in the Context sandbox.
Daan De Meyer [Sun, 10 Mar 2024 21:15:39 +0000 (22:15 +0100)]
Add grub for EFI support
We also rework the grub setup to not copy the grub modules into the
ESP anymore. We do this as grub for EFI booted in secure boot mode
does not load any unsigned modules for security reasons so we opt
to include all necessary modules into the grub image itself.