From 91832ba2b86709e36cd9d96ff67d485fd619752a Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 6 Jan 2015 00:52:39 +0100 Subject: [PATCH] Refactor _run_proot function --- lib/core.sh | 8 ++++---- tests/test_core.sh | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/core.sh b/lib/core.sh index 28a31d7..b269d3d 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -168,19 +168,19 @@ function run_juju_as_root(){ } function _run_proot(){ - if ! JUJU_ENV=1 ${@} + if ! JUJU_ENV=1 ${PROOT_COMPAT} ${@} then warn "Proot error: Trying to execute proot with PROOT_NO_SECCOMP=1..." - JUJU_ENV=1 PROOT_NO_SECCOMP=1 ${@} + JUJU_ENV=1 PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} ${@} fi } function _run_juju_with_proot(){ - [ "$(${ID} 2> /dev/null )" == "0" ] && \ + [ "$(_run_proot ${ID} 2> /dev/null )" == "0" ] && \ die "You cannot access with root privileges. Use --root option instead." - if ! _run_proot ${PROOT_COMPAT} ${@} + if ! _run_proot ${@} then die "Error: Check if the juju arguments are correct or use the option juju -p \"-k 3.10\"" fi diff --git a/tests/test_core.sh b/tests/test_core.sh index 5d2e1a2..7ea32d5 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -174,13 +174,15 @@ function test_run_juju_with_proot_as_root(){ } function test_run_proot_seccomp(){ - local output=$(_run_proot "env" | grep "^PROOT_NO_SECCOMP") + PROOT_COMPAT=env + local output=$(_run_proot | grep "^PROOT_NO_SECCOMP") is_equal $output "" || return 1 envv(){ env | grep "^PROOT_NO_SECCOMP" } - local output=$(_run_proot "envv" 2> /dev/null | grep "^PROOT_NO_SECCOMP") + PROOT_COMPAT=envv + local output=$(_run_proot 2> /dev/null | grep "^PROOT_NO_SECCOMP") is_equal $output "PROOT_NO_SECCOMP=1" || return 1 }