mirror of
https://github.com/fsquillace/junest.git
synced 2026-01-23 10:35:36 +00:00
Fix issue #43
This commit is contained in:
parent
91832ba2b8
commit
ccb4fa6325
2 changed files with 18 additions and 17 deletions
34
lib/core.sh
34
lib/core.sh
|
|
@ -73,6 +73,7 @@ PROOT_LINK=http://static.proot.me/proot-${ARCH}
|
|||
|
||||
SH="/bin/sh --login"
|
||||
CHROOT=${JUJU_HOME}/usr/bin/arch-chroot
|
||||
TRUE=${JUJU_HOME}/usr/bin/true
|
||||
ID="${JUJU_HOME}/usr/bin/id -u"
|
||||
|
||||
################################# MAIN FUNCTIONS ##############################
|
||||
|
|
@ -154,24 +155,22 @@ function _define_chroot_args(){
|
|||
}
|
||||
|
||||
|
||||
function _define_proot_args(){
|
||||
local proot_args="$1"
|
||||
shift
|
||||
local comm=$(_define_chroot_args "$@")
|
||||
echo "$proot_args" "${comm[@]}"
|
||||
}
|
||||
|
||||
|
||||
function run_juju_as_root(){
|
||||
mkdir -p ${JUJU_HOME}/${HOME}
|
||||
JUJU_ENV=1 ${CHROOT} $JUJU_HOME /usr/bin/bash -c "mkdir -p /run/lock && $(_define_chroot_args "$@")"
|
||||
}
|
||||
|
||||
function _run_proot(){
|
||||
if ! JUJU_ENV=1 ${PROOT_COMPAT} ${@}
|
||||
local proot_args="$1"
|
||||
if ${PROOT_COMPAT} $proot_args ${TRUE} &> /dev/null
|
||||
then
|
||||
JUJU_ENV=1 ${PROOT_COMPAT} ${@}
|
||||
elif PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} $proot_args ${TRUE} &> /dev/null
|
||||
then
|
||||
warn "Proot error: Trying to execute proot with PROOT_NO_SECCOMP=1..."
|
||||
JUJU_ENV=1 PROOT_NO_SECCOMP=1 ${PROOT_COMPAT} ${@}
|
||||
else
|
||||
die "Error: Check if the juju arguments are correct or use the option juju -p \"-k 3.10\""
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -180,22 +179,23 @@ function _run_juju_with_proot(){
|
|||
[ "$(_run_proot ${ID} 2> /dev/null )" == "0" ] && \
|
||||
die "You cannot access with root privileges. Use --root option instead."
|
||||
|
||||
if ! _run_proot ${@}
|
||||
then
|
||||
die "Error: Check if the juju arguments are correct or use the option juju -p \"-k 3.10\""
|
||||
fi
|
||||
_run_proot "${@}"
|
||||
}
|
||||
|
||||
|
||||
function run_juju_as_fakeroot(){
|
||||
local comm=$(_define_proot_args "$@")
|
||||
_run_juju_with_proot "-S" ${JUJU_HOME} ${comm}
|
||||
local proot_args="$1"
|
||||
shift
|
||||
local comm=$(_define_chroot_args "$@")
|
||||
_run_juju_with_proot "-S ${JUJU_HOME} ${proot_args}" ${comm}
|
||||
}
|
||||
|
||||
|
||||
function run_juju_as_user(){
|
||||
local comm=$(_define_proot_args "$@")
|
||||
_run_juju_with_proot "-R" ${JUJU_HOME} ${comm}
|
||||
local proot_args="$1"
|
||||
shift
|
||||
local comm=$(_define_chroot_args "$@")
|
||||
_run_juju_with_proot "-R ${JUJU_HOME} $proot_args" ${comm}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ function test_run_juju_with_proot_as_root(){
|
|||
}
|
||||
|
||||
function test_run_proot_seccomp(){
|
||||
TRUE=""
|
||||
PROOT_COMPAT=env
|
||||
local output=$(_run_proot | grep "^PROOT_NO_SECCOMP")
|
||||
is_equal $output "" || return 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue