public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [RFC 1/1] test-container: block sudo usage on rootless
@ 2026-10-21 13:45 'Felix Moessbauer' via isar-users
  2026-10-26 11:44 ` 'Clara Kowalsky' via isar-users
  2026-11-06  9:57 ` 'Moessbauer, Felix' via isar-users
  0 siblings, 2 replies; 4+ messages in thread
From: 'Felix Moessbauer' via isar-users @ 2026-10-21 13:45 UTC (permalink / raw)
  To: isar-users; +Cc: clara.kowalsky, Felix Moessbauer

In rootless mode, no sudo calls must be made. However, the kas-container
ships passwordless sudo which also works in the container. To catch the
cases where sudo is called in rootless mode, we replace it in the
container entrypoint of the test container with a stub that emits a
meaningfull error message along with a non zero exit code.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
A similar approach could be implemented in the gitlab CI executor
as well.

Felix

 testsuite/dockerdata/test-container-entrypoint | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/testsuite/dockerdata/test-container-entrypoint b/testsuite/dockerdata/test-container-entrypoint
index d263760d..ba824760 100755
--- a/testsuite/dockerdata/test-container-entrypoint
+++ b/testsuite/dockerdata/test-container-entrypoint
@@ -65,14 +65,16 @@ case "$args" in
 	;;
 esac
 
+block_sudo=0
 case "$args" in
 	*"-p rootless=1"*)
+		block_sudo=1
 		;;
 	*)
 		clean_rootless_files=0
 		;;
 esac
-export clean_rootless_files
+export clean_rootless_files block_sudo
 
 mkdir /isar
 
@@ -109,6 +111,19 @@ mkdir -p ${base_dir}/overlay/work
 sudo mount -t overlay overlay -o lowerdir=/repo,upperdir=${base_dir}/overlay/upper,workdir=${base_dir}/overlay/work /isar
 sudo mount -o bind ${base_dir} /isar/build
 
+if [ "${block_sudo}" = 1 ]; then
+	blocker=$(mktemp)
+	cat <<EOF > "${blocker}"
+#!/bin/sh
+echo "ERROR: sudo is blocked in rootless test runs: sudo \$*" >&2
+exit 1
+EOF
+	sudo install -m 755 -o root -g root "${blocker}" /usr/bin/sudo.blocked
+	rm -f "${blocker}"
+	# rename, as the running sudo binary cannot be overwritten in place
+	sudo mv -f /usr/bin/sudo.blocked /usr/bin/sudo
+fi
+
 mkdir -p "${HOME}"/.config/avocado
 cat <<EOF > "${HOME}"/.config/avocado/avocado.conf
 [datadir.paths]
-- 
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/20261021134540.331832-1-felix.moessbauer%40siemens.com.

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

end of thread, other threads:[~2026-11-06 16:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 13:45 [RFC 1/1] test-container: block sudo usage on rootless 'Felix Moessbauer' via isar-users
2026-10-26 11:44 ` 'Clara Kowalsky' via isar-users
2026-11-06  9:57 ` 'Moessbauer, Felix' via isar-users
2026-11-06 16:01   ` Zhihang Wei

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