diff --git a/configure.sh b/configure.sh index 3b5f7a4a9..337c63028 100755 --- a/configure.sh +++ b/configure.sh @@ -56,11 +56,36 @@ check_container_engine() { fi touch permission_check - local inner_uid="$($1 run -v "$(pwd):/test$CONTAINER_MOUNT_OPTS" \ - --rm $2 \ - stat --format "%u" /test/permission_check 2>&1)" + + # Create a temporary file for capturing output + local temp_output_file=$(mktemp) + + # Execute the check command and redirect to the temporary file + $1 run -v "$(pwd):/test$CONTAINER_MOUNT_OPTS" \ + --rm $2 stat --format "%u" /test/permission_check \ + >"$temp_output_file" 2>&1 + local return_code=$? + + local output=$(<"$temp_output_file") + + rm "$temp_output_file" + + if [ $return_code -ne 0 ]; then + err "Command failed with return code $return_code. Output: $output" + die "Please check your $1 setup." + fi + rm permission_check + # Filter output to get inner_uid or "Permission denied" + local inner_uid=$(echo "$output" | grep -E '^[0-9]+$|Permission denied') + + # Check if inner_uid is not captured or empty + if [ -z "$inner_uid" ]; then + err "Unable to determine UID - received output: $output" + die "Please check your $1 setup." + fi + if [[ $inner_uid == *"Permission denied"* ]]; then err "The container cannot access files. Are you using SELinux?" die "Please read README.md and check your $1 setup works."