]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
19 months agoAdd link to constellation mkosi blog post 2295/head
Daan De Meyer [Tue, 16 Jan 2024 22:39:09 +0000 (23:39 +0100)] 
Add link to constellation mkosi blog post

19 months agoAdd link to "Building USIs with mkosi" blog post
Daan De Meyer [Tue, 16 Jan 2024 22:32:26 +0000 (23:32 +0100)] 
Add link to "Building USIs with mkosi" blog post

19 months agoUpdate NEWS
Daan De Meyer [Tue, 16 Jan 2024 21:26:00 +0000 (22:26 +0100)] 
Update NEWS

19 months agoUse $PACKAGEDIR when building mkosi rpm
Daan De Meyer [Tue, 16 Jan 2024 15:57:47 +0000 (16:57 +0100)] 
Use $PACKAGEDIR when building mkosi rpm

19 months agoCache depmod again
Daan De Meyer [Tue, 16 Jan 2024 15:39:05 +0000 (16:39 +0100)] 
Cache depmod again

Let's run depmod before we cache our images so that we can skip it
when doing incremental builds for kernels installed with the package
manager. depmod is noticeably slow so this speeds up kernel builds a
bit.

19 months agoFix shim signing bug
Daan De Meyer [Tue, 16 Jan 2024 13:37:51 +0000 (14:37 +0100)] 
Fix shim signing bug

sign_efi_binary() expects the full output path.

19 months agoMerge pull request #2291 from DaanDeMeyer/stuff
Jörg Behrmann [Tue, 16 Jan 2024 14:57:23 +0000 (15:57 +0100)] 
Merge pull request #2291 from DaanDeMeyer/stuff

kernel-install: Build microcode initrd

19 months agokernel-install: Build microcode initrd 2291/head
Daan De Meyer [Tue, 16 Jan 2024 13:49:20 +0000 (14:49 +0100)] 
kernel-install: Build microcode initrd

Let's make sure we build a microcode initrd as well in the
kernel-install plugin. It's a bit too complicated to reuse
the build_microcode_initrd() function we have already due to
sandboxing so we opt to duplicate it instead.

19 months agoMake archive.py independent of Context
Daan De Meyer [Tue, 16 Jan 2024 13:21:52 +0000 (14:21 +0100)] 
Make archive.py independent of Context

Let's make these functions slightly more generic by passing in a
tools directory and a sandbox instead of the full Context object.

19 months agoMake sure we open Packages output location in binary mode
Daan De Meyer [Tue, 16 Jan 2024 13:59:40 +0000 (14:59 +0100)] 
Make sure we open Packages output location in binary mode

19 months agoUse stdin/stdout for cpio/tar
Daan De Meyer [Tue, 16 Jan 2024 12:54:30 +0000 (13:54 +0100)] 
Use stdin/stdout for cpio/tar

Let's reduce the amount of stuff we have to mount in the sandbox
by making use of stdin/stdout when invoking cpio/tar.

19 months agoMerge pull request #2289 from DaanDeMeyer/news
Daan De Meyer [Tue, 16 Jan 2024 12:31:01 +0000 (13:31 +0100)] 
Merge pull request #2289 from DaanDeMeyer/news

Update NEWS

19 months agoDon't include root password in /usr/lib/credstore 2289/head
Daan De Meyer [Tue, 16 Jan 2024 12:04:58 +0000 (13:04 +0100)] 
Don't include root password in /usr/lib/credstore

19 months agoUpdate NEWS
Daan De Meyer [Tue, 16 Jan 2024 12:01:37 +0000 (13:01 +0100)] 
Update NEWS

19 months agoMerge pull request #2287 from DaanDeMeyer/stuff
Daan De Meyer [Tue, 16 Jan 2024 12:00:50 +0000 (13:00 +0100)] 
Merge pull request #2287 from DaanDeMeyer/stuff

Package manager improvements

19 months agoAdd PackageDirectories= 2287/head
Daan De Meyer [Mon, 15 Jan 2024 21:24:08 +0000 (22:24 +0100)] 
Add PackageDirectories=

Let's make it possible to serve local packages as a local repository
so that users don't have to put local paths in their Packages= setting.
We'll also allow adding more packages to this local repository in the
build script so that these can be installed in the initrd when we build
it or in a postinst or finalize script.

19 months agoMount package manager caches to their canonical locations
Daan De Meyer [Mon, 15 Jan 2024 20:57:35 +0000 (21:57 +0100)] 
Mount package manager caches to their canonical locations

Let's reduce the amount of configuration by mounting package
manager caches to their canonical locations.

19 months agoReplace flatten() with format string
Daan De Meyer [Mon, 15 Jan 2024 20:31:34 +0000 (21:31 +0100)] 
Replace flatten() with format string

19 months agoUse context.pkgmngr in one more place
Daan De Meyer [Mon, 15 Jan 2024 20:30:58 +0000 (21:30 +0100)] 
Use context.pkgmngr in one more place

19 months agoMount package manager cache directories when running scripts
Daan De Meyer [Mon, 15 Jan 2024 20:29:10 +0000 (21:29 +0100)] 
Mount package manager cache directories when running scripts

When running package managers in host scripts we want the cache
to be available as well;

19 months agoPut --mirror in cache manifest
Daan De Meyer [Mon, 15 Jan 2024 20:04:55 +0000 (21:04 +0100)] 
Put --mirror in cache manifest

19 months agoFix --mirror for CentOS and Fedora
Daan De Meyer [Mon, 15 Jan 2024 19:59:03 +0000 (20:59 +0100)] 
Fix --mirror for CentOS and Fedora

Let's unify the interface for --mirror and only require users to
specify a url and add the entire path ourselves in mkosi. This is
required to use EPEL repositories with --mirror= as the epel
repositories are mirrored under <url>/fedora/epel whereas the CentOS
Stream repositories are under <url>/centos-stream

19 months agoci: Enable Arch Linux tools tree CI again
Daan De Meyer [Tue, 16 Jan 2024 09:33:54 +0000 (10:33 +0100)] 
ci: Enable Arch Linux tools tree CI again

The required qemu fix was backported to the qemu package.

19 months agoGenerate more strict regexes from loaded modules
Daan De Meyer [Tue, 16 Jan 2024 10:11:54 +0000 (11:11 +0100)] 
Generate more strict regexes from loaded modules

Let's only match actual modules ending in .ko.

19 months agofedora: Don't download filelists
Daan De Meyer [Mon, 15 Jan 2024 13:16:30 +0000 (14:16 +0100)] 
fedora: Don't download filelists

Fixes a bug introduced in c1bef56eafb6809a91816c3c17e57050c1724fc4.

19 months agoMerge pull request #2285 from DaanDeMeyer/tmpfiles
Jörg Behrmann [Mon, 15 Jan 2024 10:59:14 +0000 (11:59 +0100)] 
Merge pull request #2285 from DaanDeMeyer/tmpfiles

Run systemd-tmpfiles as part of the build

19 months agoRun systemd-tmpfiles as part of the build 2285/head
Daan De Meyer [Sun, 14 Jan 2024 20:53:06 +0000 (21:53 +0100)] 
Run systemd-tmpfiles as part of the build

Let's make sure we take user provided tmpfiles snippets into account
as well. Since systemd now mounts the initramfs read-only by default,
we need to make sure all tmpfiles snippets that copy to /etc have
already been processed during the image build itself as they won't be
able to run during the initramfs stage.

19 months agoUse 1. for ordered list
Daan De Meyer [Sun, 14 Jan 2024 20:58:41 +0000 (21:58 +0100)] 
Use 1. for ordered list

The actual number used doesn't matter, so just use 1. everywhere.

19 months agoSkip normalize_mtime() if the directory does not exist
Daan De Meyer [Sun, 14 Jan 2024 19:50:08 +0000 (20:50 +0100)] 
Skip normalize_mtime() if the directory does not exist

19 months agoMerge pull request #2283 from DaanDeMeyer/arch
Daan De Meyer [Sun, 14 Jan 2024 19:38:23 +0000 (20:38 +0100)] 
Merge pull request #2283 from DaanDeMeyer/arch

Make sure /etc/mtab exists in sandbox

19 months agoMake sure /etc/mtab exists in sandbox 2283/head
Daan De Meyer [Sun, 14 Jan 2024 17:02:39 +0000 (18:02 +0100)] 
Make sure /etc/mtab exists in sandbox

Required for pacman's CheckSpace option. To avoid messing with the
package manager tree /etc too much, we bind mount individual
subdirectories of it instead of the entire directory.

19 months agoMerge pull request #2279 from DaanDeMeyer/rpm-build
Jörg Behrmann [Sun, 14 Jan 2024 18:40:58 +0000 (19:40 +0100)] 
Merge pull request #2279 from DaanDeMeyer/rpm-build

Drop rpm-build from 30-rpm default image config

19 months agoMake sure we don't build the same tools tree more than once
Daan De Meyer [Sun, 14 Jan 2024 16:16:05 +0000 (17:16 +0100)] 
Make sure we don't build the same tools tree more than once

We can do this by simply checking if the output path already exists
instead of relying on needs_build(). This allows us to refactor
needs_build() to needs_clean(). We also move some prechecks into
run_build() and run_clean() so as to not duplicate them and improve
the logging messages in run_clean().

Fixes #2280

19 months agoBe more careful with mounting /etc/alternatives in relaxed mode
Daan De Meyer [Sun, 14 Jan 2024 16:57:34 +0000 (17:57 +0100)] 
Be more careful with mounting /etc/alternatives in relaxed mode

Otherwise we might end up trying to create a mountpoint in the host's
/etc.

19 months agoAdd BuildSources=. to the default image configuration 2279/head
Daan De Meyer [Fri, 12 Jan 2024 14:28:41 +0000 (15:28 +0100)] 
Add BuildSources=. to the default image configuration

If we enable the rpm build, we set BuildSources= which means we
override the default build sources. However we still want the source
directory to be used as BuildSources= as well, so configure it explicitly.

19 months agoSimplify run_prepare_scripts()
Daan De Meyer [Fri, 12 Jan 2024 14:23:44 +0000 (15:23 +0100)] 
Simplify run_prepare_scripts()

Make it look more like the other script functions.

19 months agoUse finalize_ephemeral_source_mounts() for package managers as well
Daan De Meyer [Fri, 12 Jan 2024 14:41:22 +0000 (15:41 +0100)] 
Use finalize_ephemeral_source_mounts() for package managers as well

Otherwise we'll still  create mountpoints in the actual source
directories when using nested build sources.

19 months agoDrop rpm-build from 30-rpm default image config
Daan De Meyer [Fri, 12 Jan 2024 13:50:20 +0000 (14:50 +0100)] 
Drop rpm-build from 30-rpm default image config

We already install it unconditionally these days.

19 months agoRelease 20.1 v20.1
Luca Boccassi [Fri, 12 Jan 2024 13:41:06 +0000 (13:41 +0000)] 
Release 20.1

19 months agoAdd note on BuildSources= being required to install local packages.
Daan De Meyer [Fri, 12 Jan 2024 12:10:09 +0000 (13:10 +0100)] 
Add note on BuildSources= being required to install local packages.

19 months agoVerify that output path is not a symlink in needs_build()
Daan De Meyer [Fri, 12 Jan 2024 11:30:41 +0000 (12:30 +0100)] 
Verify that output path is not a symlink in needs_build()

Otherwise if we first build a disk image and then try to run
"mkosi -t directory qemu" we won't actually rebuild the image as it
will think the output already exists and we'll try to boot a disk
image as a directory.

19 months agoUpdate NEWS
Daan De Meyer [Fri, 12 Jan 2024 11:03:00 +0000 (12:03 +0100)] 
Update NEWS

19 months agoMerge pull request #2275 from DaanDeMeyer/selinux
Daan De Meyer [Fri, 12 Jan 2024 10:30:39 +0000 (11:30 +0100)] 
Merge pull request #2275 from DaanDeMeyer/selinux

Improve SELinux binary policy selection

19 months agoAdd debug log when we don't add microcode initrd 2275/head
Daan De Meyer [Fri, 12 Jan 2024 09:50:09 +0000 (10:50 +0100)] 
Add debug log when we don't add microcode initrd

19 months agoAllow gpg access to /run/pscsd/pscsd.comm on the host if it exists
Daan De Meyer [Fri, 12 Jan 2024 09:33:26 +0000 (10:33 +0100)] 
Allow gpg access to /run/pscsd/pscsd.comm on the host if it exists

This is required for gpg to communicate with pscsd for interaction
with smartcards so let's mount it in if it exists.

19 months agoImprove SELinux binary policy selection
Daan De Meyer [Fri, 12 Jan 2024 09:15:53 +0000 (10:15 +0100)] 
Improve SELinux binary policy selection

Let's deal with the possibility that there might be more than one
policy in the binary policy directory. Let's also make sure that we
consider other files in the directory that might not be policies.

19 months agoPopulate only using the archlinux keyring
Daan De Meyer [Thu, 11 Jan 2024 19:26:07 +0000 (20:26 +0100)] 
Populate only using the archlinux keyring

Otherwise on Debian and Ubuntu we end up adding the Debian/Ubuntu
keyrings as well which is useless and slows down builds.

19 months agoMerge pull request #2271 from DaanDeMeyer/fix
Daan De Meyer [Thu, 11 Jan 2024 19:20:44 +0000 (20:20 +0100)] 
Merge pull request #2271 from DaanDeMeyer/fix

Two fixes

19 months agoUse grub binaries from tools tree instead of from image 2271/head
Daan De Meyer [Thu, 11 Jan 2024 13:07:20 +0000 (14:07 +0100)] 
Use grub binaries from tools tree instead of from image

Let's give this another try and use grub tools from the tools tree
instead of from the image.

We also hardcode the grub prefix per distribution because if we use
grub binaries from the tools tree there might not be any installed
in the image itself which means we can't derive the prefix from the
binaries in the image.

19 months agoUse default_factory for tools tree options defaults
Daan De Meyer [Thu, 11 Jan 2024 16:15:46 +0000 (17:15 +0100)] 
Use default_factory for tools tree options defaults

19 months agoSilence mkfs.erofs in CI
Daan De Meyer [Thu, 11 Jan 2024 15:34:16 +0000 (16:34 +0100)] 
Silence mkfs.erofs in CI

It prints a line for each file included in the image when connected
to a pipe which is extremely noisy so silence it.

19 months agoPrefer qemu-system-xxx binaries
Daan De Meyer [Thu, 11 Jan 2024 13:08:25 +0000 (14:08 +0100)] 
Prefer qemu-system-xxx binaries

The qemu and qemu-kvm binaries are just shorthands for specific configs.
Let's prefer the actual binaries over the shorthands.

19 months agoLog before going into debug shell
Daan De Meyer [Thu, 11 Jan 2024 07:55:13 +0000 (08:55 +0100)] 
Log before going into debug shell

Fixes #2269

19 months agoCheck for all required setfiles inputs in want_selinux_relabel()
Daan De Meyer [Wed, 10 Jan 2024 15:47:58 +0000 (16:47 +0100)] 
Check for all required setfiles inputs in want_selinux_relabel()

On Debian when policycoreutils is installed a policy is configured
without a matching binary policy being installed, so we have to
check that all parts are there.

19 months agoSkip caching if Overlay= is enabled
Daan De Meyer [Wed, 10 Jan 2024 11:20:29 +0000 (12:20 +0100)] 
Skip caching if Overlay= is enabled

When Overlay= is enabled we can't do Incremental= caching so skip
save_cache() if Overlay= is enabled.

19 months agoCopy nspawn settings to the output directory again
Daan De Meyer [Wed, 10 Jan 2024 09:58:29 +0000 (10:58 +0100)] 
Copy nspawn settings to the output directory again

machinectl pull-tar looks for a settings file so let's make sure
the output directory can be used directly for this purpose by copying
the nspawn settings file to the output directory again.

19 months agoMerge pull request #2263 from DaanDeMeyer/fix
Daan De Meyer [Wed, 10 Jan 2024 09:48:28 +0000 (10:48 +0100)] 
Merge pull request #2263 from DaanDeMeyer/fix

Fix invoked_as_root initialization

19 months agoActually call configure_extension_release() 2263/head
Daan De Meyer [Wed, 10 Jan 2024 08:10:44 +0000 (09:10 +0100)] 
Actually call configure_extension_release()

19 months agoFix invoked_as_root check
Daan De Meyer [Wed, 10 Jan 2024 07:22:43 +0000 (08:22 +0100)] 
Fix invoked_as_root check

19 months agoMerge pull request #2262 from DaanDeMeyer/sources
Daan De Meyer [Tue, 9 Jan 2024 21:00:57 +0000 (22:00 +0100)] 
Merge pull request #2262 from DaanDeMeyer/sources

Mount BuildSources= when executing package managers

19 months agoUse the directory mkosi was invoked in as the default for BuildSources= 2262/head
Daan De Meyer [Tue, 9 Jan 2024 19:22:59 +0000 (20:22 +0100)] 
Use the directory mkosi was invoked in as the default for BuildSources=

While parsing config, we use chdir(). Also, when a BuildSources=
match is found, BuildSources= is initialized to its default value
which is Path.cwd(). However, we want the default value to be the
top level directory that mkosi was invoked in, not the current working
directory that we happen to be in while parsing configuration. Let's
fix this by using the directory mkosi was invoked in instead of Path.cwd().

19 months agoMount in local mirror if it is provided.
Daan De Meyer [Tue, 9 Jan 2024 18:57:16 +0000 (19:57 +0100)] 
Mount in local mirror if it is provided.

19 months agoMount BuildSources= when executing package managers
Daan De Meyer [Tue, 9 Jan 2024 18:48:44 +0000 (19:48 +0100)] 
Mount BuildSources= when executing package managers

Users might have local packages which need to be mounted into the
sandbox as well. Let's make this possible by using BuildSources=.

19 months agoNEWS: reword a sentence and add punctuation
Zbigniew Jędrzejewski-Szmek [Tue, 9 Jan 2024 15:30:54 +0000 (16:30 +0100)] 
NEWS: reword a sentence and add punctuation

19 months agoFix typos in manpage
Luca Boccassi [Tue, 9 Jan 2024 15:35:24 +0000 (15:35 +0000)] 
Fix typos in manpage

19 months agoRelease 20 v20
Luca Boccassi [Tue, 9 Jan 2024 15:05:32 +0000 (15:05 +0000)] 
Release 20

19 months agoMake sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies
Daan De Meyer [Tue, 9 Jan 2024 12:12:37 +0000 (13:12 +0100)] 
Make sure SYSTEMD_REPART_MKFS_OPTIONS_<fs> always applies

Let's make sure we always use the extra mkfs options configured in
these environment variables.

We also stop filtering the environment we pass to systemd-repart.

19 months agoOnly run mount --make-rslave / if we didn't unshare a user namespace
Daan De Meyer [Tue, 9 Jan 2024 10:24:18 +0000 (11:24 +0100)] 
Only run mount --make-rslave / if we didn't unshare a user namespace

When unsharing a mount namespace in a different user namespace than
the parent mount namespace, all mounts are marked as slave by default
so we don't need to explicitly mark all of them as slave mounts.

19 months agoMerge pull request #2258 from DaanDeMeyer/policycoreutils
Jörg Behrmann [Tue, 9 Jan 2024 12:08:44 +0000 (13:08 +0100)] 
Merge pull request #2258 from DaanDeMeyer/policycoreutils

Add policycoreutils to tools trees

19 months agoAdd policycoreutils to tools trees 2258/head
Daan De Meyer [Tue, 9 Jan 2024 11:11:51 +0000 (12:11 +0100)] 
Add policycoreutils to tools trees

This package provides setfiles which is required for selinux
relabeling.

19 months agoAdd Ubuntu to tools trees docs packages list
Daan De Meyer [Tue, 9 Jan 2024 11:11:16 +0000 (12:11 +0100)] 
Add Ubuntu to tools trees docs packages list

19 months agoMerge pull request #2255 from DaanDeMeyer/simplify
Daan De Meyer [Tue, 9 Jan 2024 10:10:25 +0000 (11:10 +0100)] 
Merge pull request #2255 from DaanDeMeyer/simplify

Simplify apivfs_cmd() and chroot_cmd()

19 months agoUnshare IPC namespace when not in relaxed mode 2255/head
Daan De Meyer [Tue, 9 Jan 2024 09:26:03 +0000 (10:26 +0100)] 
Unshare IPC namespace when not in relaxed mode

Otherwise tests in the sandbox will think they have access to IPC
stuff when they actually don't.

Fixes #2256

19 months agoOnly set --security-label if the filesystem was relabeled
Daan De Meyer [Tue, 9 Jan 2024 07:49:00 +0000 (08:49 +0100)] 
Only set --security-label if the filesystem was relabeled

Otherwise we run into virtiofsd errors when operating on non relabeled
directories with --security-label enabled.

19 months agoSimplify apivfs_cmd() and chroot_cmd()
Daan De Meyer [Mon, 8 Jan 2024 22:31:37 +0000 (23:31 +0100)] 
Simplify apivfs_cmd() and chroot_cmd()

We move the setpgid logic to run(), avoiding the need to pass a tools
argument to chroot_cmd() and apivfs_cmd().

We also try to remove as much logic from these functions as possible.
Since we can't really assume that any logic we execute during the
function will still hold true in the sandbox, so it's best to delay
any logic execution until we're already in the sandbox (using the
--ro-bind-try options of bubblewrap).

We also rework the /etc/resolv.conf handling to simply make sure that
/run/systemd/resolve exists in the chroot since if /etc/resolv.conf
points to /run it'll almost certainly be to
/run/systemd/resolv/stub-resolv.conf.

19 months agoBind mount /work into chroot instead of individual files/directories
Daan De Meyer [Mon, 8 Jan 2024 19:01:33 +0000 (20:01 +0100)] 
Bind mount /work into chroot instead of individual files/directories

Same effect with less code.

19 months agoMerge pull request #2253 from DaanDeMeyer/fix
Daan De Meyer [Mon, 8 Jan 2024 18:40:26 +0000 (19:40 +0100)] 
Merge pull request #2253 from DaanDeMeyer/fix

More sandboxing fixes

19 months agoUse /work for host scripts as well 2253/head
Daan De Meyer [Mon, 8 Jan 2024 15:56:31 +0000 (16:56 +0100)] 
Use /work for host scripts as well

Now that everything runs sandboxed, /work is free to use for host
scripts as well. At the same time, let's stop unconditionally
mounting the current working directory when running build scripts.

To keep things working smoothly, we'll make mounting the current
working directory the default value for BuildSources= instead.

19 months agoReset default values when assigning the empty string to list setting
Daan De Meyer [Mon, 8 Jan 2024 16:38:11 +0000 (17:38 +0100)] 
Reset default values when assigning the empty string to list setting

For list based settings, it makes more sense for the empty string
to get rid of any default value as well.

19 months agoChange directory to the root directory in Mkosi.default()
Daan De Meyer [Mon, 8 Jan 2024 16:34:32 +0000 (17:34 +0100)] 
Change directory to the root directory in Mkosi.default()

Let's make sure subsequent invocations of Mkosi.default() return
the same value even if we default some settings to the current
working directory.

19 months agodebian: Use ?exact-name() instead of ?name()
Daan De Meyer [Mon, 8 Jan 2024 14:55:55 +0000 (15:55 +0100)] 
debian: Use ?exact-name() instead of ?name()

19 months agoAlways use /var/tmp in apivfs_cmd()
Daan De Meyer [Mon, 8 Jan 2024 14:54:26 +0000 (15:54 +0100)] 
Always use /var/tmp in apivfs_cmd()

apivfs_cmd() is always executed from within a sandbox so we can
just reuse the sandboxes /var/tmp.

19 months agoDon't use host's /var/tmp in sandbox
Daan De Meyer [Mon, 8 Jan 2024 14:52:15 +0000 (15:52 +0100)] 
Don't use host's /var/tmp in sandbox

Instead, use a subdirectory of the host's /var/tmp. Because we want
to limit the lifetime of this directory to the lifetime of the sandbox,
we use a shell command to create and remove the directory.

19 months agoPut tmpfs on /tmp in sandbox when not in relaxed mode
Daan De Meyer [Mon, 8 Jan 2024 14:21:01 +0000 (15:21 +0100)] 
Put tmpfs on /tmp in sandbox when not in relaxed mode

Let's sandbox more by not using the host's /tmp but instead putting
a fresh tmpfs on /tmp. We used the host's /tmp before because the
definitions could potentially be in the host's /tmp but now that we
mount everything in explicitly that isn't a problem anymore.

19 months agoMount cache directory before all other mounts
Daan De Meyer [Mon, 8 Jan 2024 14:00:14 +0000 (15:00 +0100)] 
Mount cache directory before all other mounts

The cache directory could potentially be /var so to avoid overriding
other mounts we have to mount it first.

19 months agoOnly mount package manager specific directories into sandbox
Daan De Meyer [Mon, 8 Jan 2024 13:51:48 +0000 (14:51 +0100)] 
Only mount package manager specific directories into sandbox

19 months agoDon't rely on /tmp being mounted into the sandbox
Daan De Meyer [Mon, 8 Jan 2024 13:49:04 +0000 (14:49 +0100)] 
Don't rely on /tmp being mounted into the sandbox

Let's not rely on /tmp implicitly being mounted in the sandbox.

19 months agoMerge pull request #2252 from DaanDeMeyer/ci
Daan De Meyer [Mon, 8 Jan 2024 13:47:29 +0000 (14:47 +0100)] 
Merge pull request #2252 from DaanDeMeyer/ci

ci: Enable Debian builds with tools trees again

19 months agoFix grub sandboxing 2252/head
Daan De Meyer [Mon, 8 Jan 2024 13:02:19 +0000 (14:02 +0100)] 
Fix grub sandboxing

19 months agoRemove a few TODOs and FIXMEs
Daan De Meyer [Mon, 8 Jan 2024 11:50:23 +0000 (12:50 +0100)] 
Remove a few TODOs and FIXMEs

19 months agodebian: Use testing again instead of unstable for default image
Daan De Meyer [Mon, 8 Jan 2024 11:43:27 +0000 (12:43 +0100)] 
debian: Use testing again instead of unstable for default image

systemd v255 is now in testing so let's use testing again instead
of unstable.

19 months agoci: Enable Debian builds with tools trees again
Daan De Meyer [Mon, 8 Jan 2024 11:41:35 +0000 (12:41 +0100)] 
ci: Enable Debian builds with tools trees again

The required fix in systemd is now in Debian so let's try enabling
these again.

19 months agoMount certificate directories into curl sandbox
Daan De Meyer [Mon, 8 Jan 2024 11:33:09 +0000 (12:33 +0100)] 
Mount certificate directories into curl sandbox

curl needs access to certificates to do its job so mount them in.

19 months agoMerge pull request #2250 from DaanDeMeyer/fix
Daan De Meyer [Mon, 8 Jan 2024 11:23:16 +0000 (12:23 +0100)] 
Merge pull request #2250 from DaanDeMeyer/fix

sandbox: Only mount host dirs that exist

19 months agoStart virtiofsd with --security-label 2250/head
Daan De Meyer [Mon, 8 Jan 2024 10:32:27 +0000 (11:32 +0100)] 
Start virtiofsd with --security-label

This makes sure selinux relabeling works as expected when booting
off virtiofs

19 months agoMount /sys, /run and /dev in relaxed mode as well
Daan De Meyer [Mon, 8 Jan 2024 10:32:14 +0000 (11:32 +0100)] 
Mount /sys, /run and /dev in relaxed mode as well

19 months agoOnly mount /etc/resolv.conf into sandbox if not in relaxed mode
Daan De Meyer [Mon, 8 Jan 2024 10:25:37 +0000 (11:25 +0100)] 
Only mount /etc/resolv.conf into sandbox if not in relaxed mode

In relaxed mode we already mount /etc so no need to mount resolv.conf
separately.

19 months agosandbox: Only mount host dirs that exist
Daan De Meyer [Mon, 8 Jan 2024 10:20:52 +0000 (11:20 +0100)] 
sandbox: Only mount host dirs that exist

19 months agoUpdate NEWS
Daan De Meyer [Mon, 8 Jan 2024 09:44:04 +0000 (10:44 +0100)] 
Update NEWS

19 months agoUse bubblewrap to set up the tools tree instead of doing it ourselves
Daan De Meyer [Tue, 2 Jan 2024 07:37:40 +0000 (08:37 +0100)] 
Use bubblewrap to set up the tools tree instead of doing it ourselves

The problem with overmounting the host's /usr (in a private mount
namespace) is that we have no control over the symlinks in the root
directory (/lib, /bin, /lib64) and if these symlinks don't match
between the host distribution and the tools tree distribution, all
kinds of weird breakage starts happening. For example, using Fedora
tools trees on Arch Linux is currently broken because /lib64 on Arch
Linux points to /usr/lib whereas on Fedora it points to /usr/lib64.

Because we can't (and shouldn't) modify the symlinks of the host's
root filesystem, we need to set up the tools tree in a sandbox that
we chroot into, so that we have full control over the rootfs of the
sandbox and can make sure the symlinks are correct. Luckily, we
already do just that with bubblewrap, except that currently we mount
the tools tree over /usr ourselves and then just carry that over into
the bubblewrap sandbox.

Instead, we stop mounting over the host's /usr ourselves and have
bubblewrap pick the right /usr itself. We also copy the symlinks from
the tools tree or the host if there is no tools tree.

Because we don't mount over the host's /usr anymore, we have to run
every tool that should come from the tools tree with bubblewrap now.
The side effect of this is that almost all of our tools now run
sandboxed. We also have to make use of find_binary() everywhere
instead of shutil.which() to make sure we look for binaries in the
tools tree when required. Various other codepaths that look into /usr
also have to be modified to look into the tools tree when needed.

Also, because we don't unshare the user namespace in the main mkosi
process anymore now, we can get rid of a lot of chown()'s in qemu.py
and opening the qemu device file descriptors can be moved into
run_qemu() itself.

We also don't have to make sure all python modules are loaded anymore
as the host's /usr is never overmounted so the required python modules
will be available for the entire runtime of the mkosi process.

Because virtiofsd is now executed with bubblewrap, we use bubblewrap
to set up the required uidmap instead of relying on virtiofsd to do it
with newuidmap/newgidmap. Note that this breaks RuntimeTrees= as
virtiofsd unconditionally tries to drop groups with setgroups() which
fails with EPERM in an unprivileged user namespace set up by bubblewrap.
This is fixed by https://gitlab.com/virtio-fs/virtiofsd/-/merge_requests/207
which is still awaiting review.

To make this work codewise, this commit renames the bwrap() function
to sandbox_cmd() (similar to chroot_cmd() and apivfs_cmd()) which now
returns a command line instead of executing the command itself. run()
is modified to take an extra "sandbox" arguments which is simply the
part of the full command that sets up the sandbox. Context and Config
both learn new sandbox() methods which set up the sandbox for each
object respectively (mostly by adding extra bind mounts).

Because almost every call to run() now takes a sandbox, this gives us
a lot of control over the individual environment for each tool we run.
We make use of this to restrict each tool we run to the minimal possible
sandbox that that tool needs to run. By specifically mounting in the
required paths for each tool we run, we also make sure these are always
available instead of relying that somewhere we mount a path that has the
input in it.

Because we allow passing arbitrary options to mkosi qemu, mkosi boot and
various other verbs, we run these verbs with a relaxed sandbox, where we
mount in most directories from the host. This means that whatever
directories users specify will be available.

In terms of CI, the extra sandboxing means that our previous approach of
building various systemd binaries from source and symlinking them to
/usr/bin doesn't work anymore. Instead, we opt to always use tools trees
and drop the host builds from the testing matrix. This also simplifies
and speeds up the github action as we don't have to compile systemd and
xfsprogs from source and we have to install fewer packages.