From 498320de8a9c263ade3381e43027458cde38bfa7 Mon Sep 17 00:00:00 2001 From: Tin Lai Date: Wed, 24 May 2023 14:14:57 +1000 Subject: [PATCH] fix PATH variable being empty in trapped function Signed-off-by: Tin Lai --- lib/core/namespace.sh | 2 ++ lib/core/proot.sh | 1 + lib/core/wrappers.sh | 1 + 3 files changed, 4 insertions(+) diff --git a/lib/core/namespace.sh b/lib/core/namespace.sh index bbda112..f4bef71 100644 --- a/lib/core/namespace.sh +++ b/lib/core/namespace.sh @@ -103,6 +103,7 @@ function run_env_as_bwrap_fakeroot(){ # Fix PATH to /usr/bin to make sudo working and avoid polluting with host related bin paths # shellcheck disable=SC2086 + local JUNEST_ORIGINAL_PATH="$PATH" PATH="/usr/bin" BWRAP="${backend_command}" JUNEST_ENV=1 bwrap_cmd $COMMON_BWRAP_OPTION --cap-add ALL --uid 0 --gid 0 $backend_args sudo "${DEFAULT_SH[@]}" "${args[@]}" } @@ -153,6 +154,7 @@ function run_env_as_bwrap_user() { # Resets PATH to avoid polluting with host related bin paths # shellcheck disable=SC2086 + local JUNEST_ORIGINAL_PATH="$PATH" PATH='' BWRAP="${backend_command}" JUNEST_ENV=1 bwrap_cmd $COMMON_BWRAP_OPTION $backend_args "${DEFAULT_SH[@]}" "${args[@]}" } diff --git a/lib/core/proot.sh b/lib/core/proot.sh index b6c1c8f..90d8c6a 100644 --- a/lib/core/proot.sh +++ b/lib/core/proot.sh @@ -18,6 +18,7 @@ function _run_env_with_proot(){ [[ "$1" != "" ]] && args=("-c" "$(insert_quotes_on_spaces "${@}")") # Resets PATH to avoid polluting with host related bin paths + local JUNEST_ORIGINAL_PATH="$PATH" PATH='' PROOT="${backend_command}" JUNEST_ENV=1 proot_cmd "${backend_args}" "${DEFAULT_SH[@]}" "${args[@]}" } diff --git a/lib/core/wrappers.sh b/lib/core/wrappers.sh index 1fe955c..4d147ea 100644 --- a/lib/core/wrappers.sh +++ b/lib/core/wrappers.sh @@ -19,6 +19,7 @@ # None ####################################### function create_wrappers() { + local PATH="${JUNEST_ORIGINAL_PATH:-"$PATH"}" local force=${1:-false} local bin_path=${2:-/usr/bin} bin_path=${bin_path%/}