diff --git a/lib/core.sh b/lib/core.sh index afce54c..0b299c4 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -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 } diff --git a/tests/test_core.sh b/tests/test_core.sh index 38d7b41..d2a6aea 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -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(){