From: Jan Kiszka <
jan.k...@siemens.com>
Rather than only spitting out warnings but otherwise happily continuing,
issue a clear error message and bail out in case binfmt_misc cannot be
mounted or configured. This could happen, e.g., when using for rootless
mode a kernel older than 6.7, i.e. without namespace support.
Signed-off-by: Jan Kiszka <
jan.k...@siemens.com>
---
container-entrypoint | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/container-entrypoint b/container-entrypoint
index 4876386..0725a8c 100755
--- a/container-entrypoint
+++ b/container-entrypoint
@@ -2,7 +2,7 @@
#
# kas - setup tool for bitbake based projects
#
-# Copyright (c) Siemens AG, 2017-2023
+# Copyright (c) Siemens AG, 2017-2026
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -22,18 +22,26 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-enable_qemu_binfmts()
+do_enable_qemu_binfmts()
{
if ! [ -f /proc/sys/fs/binfmt_misc/status ]; then
- sudo mount -t binfmt_misc null /proc/sys/fs/binfmt_misc
+ sudo mount -t binfmt_misc null /proc/sys/fs/binfmt_misc || return
fi
for CONF in /usr/lib/binfmt.d/qemu-*.conf; do
if ! [ -f /proc/sys/fs/binfmt_misc/"$(basename "${CONF%%.conf}")" ]; then
- sudo sh -c "cat '$CONF' > /proc/sys/fs/binfmt_misc/register"
+ sudo sh -c "cat '$CONF' > /proc/sys/fs/binfmt_misc/register" || return
fi
done
}
+enable_qemu_binfmts()
+{
+ if ! do_enable_qemu_binfmts; then
+ echo "kas-container: failed to set up binfmt_misc" >&2
+ exit 1
+ fi
+}
+
# For rootless nesting of the uid_ns, we need to provide a list of sub
# uids/gids which can be used in the sub namespace. As each id in the
# sub namespace must be mappable into the parent namespace, we need to
--
2.47.3