Daan De Meyer [Thu, 6 Feb 2025 13:40:36 +0000 (14:40 +0100)]
tree: Don't copy xattrs to overlayfs if security.selinux is one
Trying to copy the selinux xattrs to a directory in an overlayfs
filesystem will fail with "Operation not supported". There's no way
to instruct cp to not copy or ignore failures to copy selinux xattrs
so let's instead not try to copy xattrs at all when copying to directories
in overlayfs filesystems and security.selinux is in the list of xattrs.
Daan De Meyer [Thu, 6 Feb 2025 11:05:05 +0000 (12:05 +0100)]
rpm: Fix root locations for GPG searching
We should always look in the tools tree for /usr/share/distribution-gpg-keys,
regardless of the value of ToolsTreeCertificates= since the setting has no
impact on which /usr/share/distribution-gpg-keys directory we end up using.
We should look in the host or tools tree for /etc/pki/rpm-gpg, based on the
value of ToolsTreeCertificates=, not in the sandbox tree, because the /etc/pki
directory from the host or tools tree will always be used and mounted over the
directory from the sandbox tree, so there's no point in looking for rpm gpg keys
in the sandbox tree at all.
Daan De Meyer [Thu, 6 Feb 2025 09:54:45 +0000 (10:54 +0100)]
fedora: Try to load N+1 key from distribution-gpg-keys as well
Fetching the rawhide keys from the distribution-gpg-keys github
repository faces the same problem that we have when using the locally
installed distribution-gpg-keys, the rawhide symlink might not have
been updated yet at branching time, so apply the same solution and
try to load the N+1 key as well.
Martin Hundebøll [Tue, 28 Jan 2025 20:35:26 +0000 (21:35 +0100)]
Support unsigned verity backed extension/portable images
Building an unsigned extension image with verity hashes provides data
integrity without needing a certificate on the target machine.
Note that systemd-dissect and systemd-sysext doesn't automatically
use the verity data has partition for validation. Both tools enables
validation if the user.verity.roothash xattr is set for the image.
For systemd-dissect, one can use the --root-hash option to enable the
validation.
The root hash can be obtained by concatenating the partition uuid's for
the root and the root-verity partitions.
Daan De Meyer [Tue, 28 Jan 2025 19:47:30 +0000 (20:47 +0100)]
Don't call have_cache() in reuse_cache()
By the time reuse_cache() is called, we've already cleaned up old
cached images if needed, so just check if they still exist and reuse
them if they do.
Daan De Meyer [Tue, 28 Jan 2025 19:18:36 +0000 (20:18 +0100)]
Replace check_uid with a "tools" image check in have_cache()
We have access to the config object in have_cache() and this argument
is specifically intended to be used whenever we pass the default tools
tree to have_cache(), so let's just do the check based on config.image
in have_cache() itself.
Martin Hundebøll [Mon, 27 Jan 2025 14:45:01 +0000 (15:45 +0100)]
Fix verity signature check in case keys are configured
The repart json output includes the architecture in the partiton type
string, so the same must be included when checking for a verity
signature partition.
Daan De Meyer [Mon, 27 Jan 2025 14:05:45 +0000 (15:05 +0100)]
mkosi-tools: Drop fish and zsh
These are a bit too exquisite to have in the default tools tree and
we don't start a shell in mkosi-sandbox by default anymore, so let's
stick to just having bash in the default tools tree.
zypper allows to use the `$releasever` variable in repo URLs (see zypper(8) man
page). When mkosi uses zypper repos from the host instead of the default ones,
this variable needs to be replaced with the host's `VERSION_ID`, otherwise repo
URLs are incomplete.
Daan De Meyer [Mon, 27 Jan 2025 10:10:13 +0000 (11:10 +0100)]
Log command line for abnormal signals
If we're not killed by SIGINT or SIGTERM, let's log the command line
as in this scenario it's very likely the process we were running crashed
with SIGABRT or SIGSEGV.
Daan De Meyer [Sat, 25 Jan 2025 21:28:21 +0000 (22:28 +0100)]
mkosi-initrd: Add two more modules
Three more generic modules that are needed in the initrd.
- mxm-wmi is a standard for switchable laptop graphics
- usb-storage is obviously for USB storage devices
- partport (https://docs.kernel.org/admin-guide/parport.html)
seems generic enough that we should include it in the initrd.
Daan De Meyer [Fri, 24 Jan 2025 12:04:45 +0000 (13:04 +0100)]
Make sure all config paths are absolute
With all the chdir() we do while parsing configuration, let's make
sure our config paths are absolute so that they don't suddenly
change meaning when we chdir().
Daan De Meyer [Thu, 23 Jan 2025 20:19:38 +0000 (21:19 +0100)]
Use resource_path() to access files in our own module
__file__ doesn't work if mkosi is packaged up as a zipapp, let's
use resource_path() which is specifically intended to solve this
problem and works regardless of whether we're in a zipapp or not.
Daan De Meyer [Thu, 23 Jan 2025 17:02:28 +0000 (18:02 +0100)]
Do not check uid in have_cache() for default tools tree
If the tools tree has a cache, it's complete, we're not going to
modify it anymore, and it doesn't matter whether the files in it
are owned by root or an unprivileged user, we'll be able to execute
binaries from it regardless, so let's not check the ownership when
we invoke have_cache() on it.
Daan De Meyer [Thu, 23 Jan 2025 14:27:48 +0000 (15:27 +0100)]
Create zipapp for mkosi sandbox like we do in generate-zipapp.sh
Otherwise we run into ModuleNotFoundError trying to run a zipapp
created from a packaged version of mkosi. This is the same
workaround that's already used in generate-zipapp.sh.
Daan De Meyer [Thu, 23 Jan 2025 08:12:14 +0000 (09:12 +0100)]
Simplify crypto-policies copying
To make matters even more interesting, aside from a bunch of .txt
files in /usr/share/crypto-policies/DEFAULT, there's also the same
files in /usr/share/crypto-policies/back-ends/DEFAULT, but they do
have the .config extension there, so lets simplify the logic by
copying from that location.
Daan De Meyer [Wed, 22 Jan 2025 16:11:56 +0000 (17:11 +0100)]
Add support for FirmwareVariables=microsoft-mok
This new setting will use firmware variables with enrolled microsoft
keys and extend them with the required MOK variables to trust the
user's secure boot key/certificate.
This is the first time this appears in the partcular boot's logs and we always
ignore it and carry on. Let's sidestep checking whether it is this particular
error by masking the unit.
A possible reason might be that it gets pulled in by udev if a test using LVM
runs first.
Daan De Meyer [Wed, 22 Jan 2025 16:07:09 +0000 (17:07 +0100)]
Don't insist on pre-signed EFI binaries when ShimBootloader == signed
The whole point of shim is that you can use a presigned shim with
locally signed EFI binaries if the local key is enrolled in MOK, so
don't insist on presigned EFI binaries when a signed shim is requested.
Instead the new "signed" variants of the Bootloader= option can be used
to still force installation of presigned EFI binaries.