From: "'Felix Moessbauer' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: clara.kowalsky@siemens.com,
Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [RFC 1/1] test-container: block sudo usage on rootless
Date: Wed, 21 Oct 2026 15:45:40 +0200 [thread overview]
Message-ID: <20261021134540.331832-1-felix.moessbauer@siemens.com> (raw)
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.
next reply other threads:[~2026-10-21 13:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 13:45 'Felix Moessbauer' via isar-users [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021134540.331832-1-felix.moessbauer@siemens.com \
--to=isar-users@googlegroups.com \
--cc=clara.kowalsky@siemens.com \
--cc=felix.moessbauer@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox