public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] add script to check if the current environment supports rootless builds
@ 2026-08-21 12:58 'Felix Moessbauer' via isar-users
  2026-08-21 12:58 ` [PATCH 2/2] user_manual: document rootless build mode 'Felix Moessbauer' via isar-users
  0 siblings, 1 reply; 2+ messages in thread
From: 'Felix Moessbauer' via isar-users @ 2026-08-21 12:58 UTC (permalink / raw)
  To: isar-users; +Cc: michael.adler, jan.kiszka, Felix Moessbauer

Running builds in rootless mode has a lot of non obvious pre conditions.
To help the user check if his system is configured correctly, we provide
a script that checks the needed features. If a feature is missing, it
issues an error regarding what likely is the root cause.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 scripts/isar-check-rootless | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 scripts/isar-check-rootless

diff --git a/scripts/isar-check-rootless b/scripts/isar-check-rootless
new file mode 100755
index 00000000..61a2a2e3
--- /dev/null
+++ b/scripts/isar-check-rootless
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Copyright (C) 2026 Siemens AG
+# SPDX-License-Identifier: MIT
+#
+# Helper script to check if the current environment supports unprivileged
+# rootless builds with unshare.
+# Returns 0 if supported, otherwise returns 1 and prints an error message to stderr.
+
+if ! run_privileged_cmd=$(bitbake-getvar -q --value RUN_PRIVILEGED_CMD); then
+	echo "error: cannot determine RUN_PRIVILEGED_CMD from BitBake" >&2
+	exit 1
+fi
+
+if ! ${run_privileged_cmd} /bin/sh <<'EOF'
+	failed=0
+
+	fail() {
+		echo "error: $1" >&2
+		echo "       likely cause: $2" >&2
+		failed=1
+	}
+
+	mountpoint=$(mktemp -d)
+	if [ -n "$mountpoint" ]; then
+		if ! mount -t proc proc "$mountpoint"; then
+			fail "cannot mount procfs in the user namespace" \
+				"procfs is over-mounted by the container runtime, or the host security policy blocks procfs mounts"
+		else
+			umount "$mountpoint"
+		fi
+		rmdir "$mountpoint"
+	fi
+
+	if ! setpriv --reuid=nobody --regid=nogroup --clear-groups /usr/bin/true; then
+		fail "cannot execute as nobody:nogroup in the user namespace" \
+			"the subuid / subgid ID range is too small or incomplete"
+	fi
+
+	exit "$failed"
+EOF
+then
+	echo "error: unprivileged rootless builds are not supported; see the checks above" >&2
+	exit 1
+fi
+
+echo "unprivileged rootless builds are supported"
-- 
2.55.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20260821125806.2161496-1-felix.moessbauer%40siemens.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-21 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-21 12:58 [PATCH 1/2] add script to check if the current environment supports rootless builds 'Felix Moessbauer' via isar-users
2026-08-21 12:58 ` [PATCH 2/2] user_manual: document rootless build mode 'Felix Moessbauer' via isar-users

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox