From c19724872d1eaf1fa6ac33e0f89d6e60966c4ec5 Mon Sep 17 00:00:00 2001 From: K1ngst0m Date: Thu, 25 Jan 2024 00:20:58 +0800 Subject: [PATCH 1/2] configure.sh: Handle Podman Docker Wrapper. --- configure.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/configure.sh b/configure.sh index 3b5f7a4a9..fcfe7dea2 100755 --- a/configure.sh +++ b/configure.sh @@ -56,11 +56,22 @@ check_container_engine() { fi touch permission_check - local inner_uid="$($1 run -v "$(pwd):/test$CONTAINER_MOUNT_OPTS" \ + + # Capture both stdout and stderr + local output="$($1 run -v "$(pwd):/test$CONTAINER_MOUNT_OPTS" \ --rm $2 \ stat --format "%u" /test/permission_check 2>&1)" 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." From df2d6390e5f0d594d60001ab3235077e480b7ac4 Mon Sep 17 00:00:00 2001 From: K1ngst0m Date: Thu, 25 Jan 2024 07:34:37 +0800 Subject: [PATCH 2/2] configure.sh: Handle the return code of UID check --- configure.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/configure.sh b/configure.sh index fcfe7dea2..337c63028 100755 --- a/configure.sh +++ b/configure.sh @@ -57,10 +57,24 @@ check_container_engine() { touch permission_check - # Capture both stdout and stderr - local output="$($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"