Skip to content

Add option to disable sandbox#19

Open
ayakael wants to merge 2 commits intojirutka:masterfrom
ayakael:sandbox-optional
Open

Add option to disable sandbox#19
ayakael wants to merge 2 commits intojirutka:masterfrom
ayakael:sandbox-optional

Conversation

@ayakael
Copy link
Copy Markdown

@ayakael ayakael commented Jun 5, 2025

Fixes #18

When building AKMS packages in chroot or LXC, sandboxing isn't always possible. This adds use_sandbox boolean and --[no]-sandbox option to AKMS to disable sandboxing.

@ayakael ayakael changed the title Add option to disable sandbox WIP: Add option to disable sandbox Jun 5, 2025
@ayakael ayakael force-pushed the sandbox-optional branch from ff182a5 to 3682770 Compare June 5, 2025 18:33
@ayakael
Copy link
Copy Markdown
Author

ayakael commented Jun 5, 2025

A simpler implementation is reverting 6a37404, which would look like this:

From d9dadb254cc2fede48942bdfb883a4bab3430160 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Thu, 5 Jun 2025 14:38:07 -0400
Subject: [PATCH] Only run builds in bublewrap sandbox when using overlayfs

Reverts 6a3740411f7d7c515250261225483b67959b799b by only setting
`--sandbox` variable when `build_root` is set, which is set only when
overlayfs is used.

This fixes using `akms` in chroot environment, as bubblewrap breaks in
that context due to lack of namespace.

diff --git a/akms b/akms
index ffa92ad..77b04d7 100755
--- a/akms
+++ b/akms
@@ -593,8 +593,7 @@ build_module() {
 	chown -R "$BUILD_USER" "$builddir" || return 1
 
 	runas "$BUILD_USER" \
-		--sandbox "${build_root:-/}" \
-		--bind "$builddir" "$builddir" \
+		${build_root:+--sandbox "${build_root:-/}" --bind "$builddir" "$builddir"} \
 		srcdir="$srcdir" \
 		builddir="$builddir" \
 		kernel_ver="$kernel" \
-- 
2.49.0

This approach thus implicitely disables sandboxing when overlayfs is disabled. If this is a preferred approach, I can change the PR accordingly.

@ayakael ayakael force-pushed the sandbox-optional branch 3 times, most recently from dea6d94 to d35f038 Compare June 7, 2025 17:25
@ayakael ayakael changed the title WIP: Add option to disable sandbox Add option to disable sandbox Jun 7, 2025
@ayakael
Copy link
Copy Markdown
Author

ayakael commented Jun 7, 2025

I've tested with and without sandbox, and it works. Ready for review.

ayakael added 2 commits June 11, 2025 12:51
Some environments does not support bubblewrap (i.e. chroot). To address
this limitations, this adds `use_sandbox` boolean and `--[no]-sandbox`
option to AKMS to disable sandboxing.

AKMS kernel hooks is also modified to automatically disable sandboxing
and overlay when in chroot environment.
… of apk

When building AKMS module without sandbox, and via kernel hooks, using
`apk` to check if `build-base` is installed won't work if it was added
via the same install transaction. Thus, following the approach of
`linux-*dev` package, we check if `build-base` is installed by looking
for key files (i.e gcc, patch, make). If those key files don't exist,
`build-base` is added to `makedepends` variable.
@ayakael ayakael force-pushed the sandbox-optional branch from d35f038 to c0ae7fb Compare June 11, 2025 16:52
github-actions bot pushed a commit to dpkg123/pmaports that referenced this pull request Jun 16, 2025
AKMS builds modules in a sandbox using bubblewrap. Bubblewrap
unfortunately does not work in chroot environment, thus breaking
pmbootstrap. While a PR has been proposed upstream, history shows that
upstream takes a while to consider PRs. Thus, to unblock usage of AKMS,
this adds a patched version that allows disabling of sandbox using
`--no-sandbox` argument or by adding `use_sandbox=false` to
`/etc/akms.conf`. When building in chroot environment, sandboxing is
automatically disabled.

The aport handles conflicts with akms by setting `pkgver=9999$_pkgver`,
thus always overriding Alpine's package.

Upstream PR: jirutka/akms#19

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to disable sandbox for chroot / lxc environments

1 participant