fix PATH variable being empty in trapped function

Signed-off-by: Tin Lai <oscar@tinyiu.com>
This commit is contained in:
Tin Lai 2023-05-24 14:14:57 +10:00
parent 507502dc1a
commit 498320de8a
3 changed files with 4 additions and 0 deletions

View file

@ -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[@]}"
}

View file

@ -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[@]}"
}

View file

@ -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%/}