public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Zhihang Wei <wzh@ilbers.de>
To: Felix Moessbauer <felix.moessbauer@siemens.com>,
	isar-users@googlegroups.com
Cc: Clara Kowalsky <clara.kowalsky@siemens.com>
Subject: Re: [PATCH 1/1] test-container: block sudo usage on rootless
Date: Wed, 11 Nov 2026 17:10:01 +0100	[thread overview]
Message-ID: <8bec959b-2538-44c1-94f0-3e516f0c8012@ilbers.de> (raw)
In-Reply-To: <20261110091850.1015989-1-felix.moessbauer@siemens.com>

Applied to next, thanks.

I'll bump the test-container version later.

Zhihang

On 11/10/26 10:18, 'Felix Moessbauer' via isar-users wrote:
> 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.
>
> Tested-by: Clara Kowalsky <clara.kowalsky@siemens.com>
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>   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 49771c15..1e5aec3c 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]

-- 
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/8bec959b-2538-44c1-94f0-3e516f0c8012%40ilbers.de.

      reply	other threads:[~2026-11-11 16:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  9:18 'Felix Moessbauer' via isar-users
2026-11-11 16:10 ` Zhihang Wei [this message]

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=8bec959b-2538-44c1-94f0-3e516f0c8012@ilbers.de \
    --to=wzh@ilbers.de \
    --cc=clara.kowalsky@siemens.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.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