From 8b390b51b50a6fbfd89de1b2ad57aff0df274b6b Mon Sep 17 00:00:00 2001 From: Sudip Roy Date: Fri, 14 Nov 2025 01:02:25 +0530 Subject: [PATCH 1/2] Improve user switching in Docker execution Refactor user switching logic for container execution. --- auto_verify.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auto_verify.sh b/auto_verify.sh index 7d1106f..3f98700 100644 --- a/auto_verify.sh +++ b/auto_verify.sh @@ -82,10 +82,14 @@ run_verification() { fi fi - # Execute build script inside the container and save logs - if [ "$user" == "test" ]; then + # Determine current user inside the container + current_container_user=$(docker exec "$container_id" whoami) + + if [ "$user" == "test" ] && [ "$current_container_user" != "test" ]; then + # Only switch if not already test docker exec "$container_id" su - test -c "bash $script_path -$build_arg" &> "$log_file" else + # Already test OR user isn't test docker exec "$container_id" bash $script_path -$build_arg &> "$log_file" fi From cc87b9444132abdaa81055060c37ec2587cf5662 Mon Sep 17 00:00:00 2001 From: Sudip Roy Date: Fri, 14 Nov 2025 23:26:17 +0530 Subject: [PATCH 2/2] fix --- auto_verify.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auto_verify.sh b/auto_verify.sh index 3f98700..d04b07d 100644 --- a/auto_verify.sh +++ b/auto_verify.sh @@ -83,7 +83,11 @@ run_verification() { fi # Determine current user inside the container - current_container_user=$(docker exec "$container_id" whoami) + current_container_user=$(docker exec "$container_id" whoami) || { + echo "Failed to determine current user in container: $container_id" | tee -a "$log_file" + docker rm -f "$container_id" + return 1 + } if [ "$user" == "test" ] && [ "$current_container_user" != "test" ]; then # Only switch if not already test