Merge pull request #120 from fsquillace/fallback

Issue #113: Fix fallback for proot command
This commit is contained in:
Filippo Squillace 2015-10-15 19:39:17 +01:00
commit f6cd31996d
2 changed files with 20 additions and 9 deletions

View file

@ -125,8 +125,17 @@ function mkdir_cmd(){
}
function proot_cmd(){
${PROOT_COMPAT} "${@}" || PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} "${@}" || \
die "Error: Check if the ${CMD} arguments are correct or use the option ${CMD} -p \"-k 3.10\""
local proot_args="$1"
shift
if ${PROOT_COMPAT} ${proot_args} "${SH[@]}" "-c" ":"
then
${PROOT_COMPAT} ${proot_args} "${@}"
elif PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} ${proot_args} "${SH[@]}" "-c" ":"
then
PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} ${proot_args} "${@}"
else
die "Error: Check if the ${CMD} arguments are correct and if the kernel is too old use the option ${CMD} -p \"-k 3.10\""
fi
}
function download_cmd(){
@ -231,9 +240,9 @@ function _run_env_with_proot(){
if [ "$1" != "" ]
then
JUNEST_ENV=1 proot_cmd ${proot_args} "${SH[@]}" "-c" "$(insert_quotes_on_spaces "${@}")"
JUNEST_ENV=1 proot_cmd "${proot_args}" "${SH[@]}" "-c" "$(insert_quotes_on_spaces "${@}")"
else
JUNEST_ENV=1 proot_cmd ${proot_args} "${SH[@]}"
JUNEST_ENV=1 proot_cmd "${proot_args}" "${SH[@]}"
fi
}

View file

@ -253,10 +253,9 @@ function test_run_env_as_user(){
assertEquals "$output" "/usr/bin/mkdir"
assertTrue "[ -e $JUNEST_HOME/newdir2 ]"
SH=("/usr/bin/mkdir" "-v" "/newdir")
local output=$(run_env_as_user "-k 3.10" | awk -F: '{print $1}')
assertEquals "$output" "/usr/bin/mkdir"
assertTrue "[ -e $JUNEST_HOME/newdir ]"
SH=("/usr/bin/echo")
local output=$(run_env_as_user "-k 3.10")
assertEquals "-c :" "$output"
}
function test_run_env_as_proot_mtab(){
@ -329,7 +328,10 @@ function test_run_proot_seccomp(){
}
PROOT_COMPAT=envv
local output=$(proot_cmd 2> /dev/null | grep "^PROOT_NO_SECCOMP")
assertEquals "PROOT_NO_SECCOMP=1" "$output"
# The variable PROOT_NO_SECCOMP will be produced
# twice due to the fallback mechanism
assertEquals "PROOT_NO_SECCOMP=1
PROOT_NO_SECCOMP=1" "$output"
}
function test_run_env_as_fakeroot(){