public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Zhihang Wei <wzh@ilbers.de>
To: "Moessbauer, Felix" <felix.moessbauer@siemens.com>
Cc: "Kowalsky, Clara" <clara.kowalsky@siemens.com>,
	"isar-users@googlegroups.com" <isar-users@googlegroups.com>
Subject: Re: [RFC 1/1] test-container: block sudo usage on rootless
Date: Fri, 6 Nov 2026 17:01:31 +0100	[thread overview]
Message-ID: <5ac854b8-95ae-43e4-baab-af961d659760@ilbers.de> (raw)
In-Reply-To: <9d5951d1d2a3c41267a5c6700f17397786966f10.camel@siemens.com>


On 11/6/26 10:57, Moessbauer, Felix wrote:
> On Wed, 2026-10-21 at 15:45 +0200, Felix Moessbauer 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.
> Hi,
>
> IMHO this can be merged. If needed, I can re-send as PATCH instead of
> RFC. Just let me know.
>
> Felix
>

OK, please send it as a patch. Will test and get back to you,

Zhihang

>> 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/5ac854b8-95ae-43e4-baab-af961d659760%40ilbers.de.

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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2026-11-06 16:01   ` 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=5ac854b8-95ae-43e4-baab-af961d659760@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