sanebox: replace short-circuit eval idiom with if/else

This commit is contained in:
Colin 2024-05-17 23:21:36 +00:00
parent 85c0e72bf1
commit 26aa68ee59

View File

@ -18,7 +18,9 @@ enableDebug() {
}
debug() {
[ -n "$isDebug" ] && printf "[debug] %s" "$1" >&2
if [ -n "$isDebug" ]; then
printf "[debug] %s" "$1" >&2
fi
}
# if requested, enable debugging as early as possible
@ -549,7 +551,12 @@ firejailSetup() {
firejailIngestPath() {
# XXX: firejail flat-out refuses to whitelist certain root paths
# this exception list is non-exhaustive
[ "$1" != "/bin" ] && [ "$1" != "/etc" ] && firejailFlags+=("--noblacklist=$1" "--whitelist=$1")
case $1 in
(/bin | /etc) ;;
(*)
firejailFlags+=("--noblacklist=$1" "--whitelist=$1")
;;
esac
}
firejailIngestNet() {
firejailFlags+=("--net=$1")
@ -892,10 +899,16 @@ parseArgsAndEnvironment() {
isDisable=1
fi
test -n "$SANEBOX_PREPEND" && parseArgs $SANEBOX_PREPEND
if [ -n "$SANEBOX_PREPEND" ]; then
parseArgs $SANEBOX_PREPEND
fi
parseArgs "$@"
cliArgs+=("${parseArgsExtra[@]}")
test -n "$SANEBOX_APPEND" && parseArgs $SANEBOX_APPEND
if [ -n "$SANEBOX_APPEND" ]; then
parseArgs $SANEBOX_APPEND
fi
}
### convert generic args into sandbox-specific args