Skip to content

Commit

Permalink
add support for firejail arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
gibix committed Aug 13, 2018
1 parent 1789ac2 commit f32fb25
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions orjail
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DEFAULTNAME=orjail
NAME=$DEFAULTNAME
USERNAME=${SUDO_USER:-$(whoami)}
USEFIREJAIL=n
FIREJAILARGS=
VERBOSE=
TORBIN=
KEEP=
Expand Down Expand Up @@ -154,6 +155,8 @@ help_and_exit() {
print N " -v, --verbose Verbose mode."
print N " -k, --keep Don't delete namespace and don't kill tor after the execution."
print N " -f, --firejail Use firejail as a security container ($SUDOBIN orjail -f pidgin)."
print N " --firejail-args \"<args>\""
print N " Set arguments to pass to firejail surrounded by quotes."
print N " -y, --yes Answer all questions with \"y\" (orjail -y pidgin)."
print N " -H, --hidden <port>"
print N " Enable Tor as an hidden service forwarding request from/to specified port."
Expand Down Expand Up @@ -284,6 +287,17 @@ while [[ $# -gt 0 ]]; do
USEFIREJAIL=y
;;

--firejail-args)
FIREJAILARGS=( "$2" )
shift

if [ "${#FIREJAILARGS[@]}" -eq 0 ]; then
printv R "$key requires an argument."
exit 1
fi
USEFIREJAIL=y
;;

-y|--yes)
FORCEYES=y
;;
Expand Down Expand Up @@ -539,9 +553,9 @@ chmod a+r "$RESOLVEFILE" || die "Failed to change permissions to $RESOLVEFILE"
# use firejail as security container
if [ $USEFIREJAIL = y ]; then
if [ "$SUDOBIN" ]; then
$SUDOBIN -u "$USERNAME" "$FIREJAILBIN" --dns="$IPHOST" --netns="$NAME" "$@"
$SUDOBIN -u "$USERNAME" "$FIREJAILBIN" "${FIREJAILARGS[@]}" --dns="$IPHOST" --netns="$NAME" "$@"
else
su "$USERNAME" -c "$FIREJAILBIN --dns=$IPHOST --netns=$NAME $*"
su "$USERNAME" -c "$FIREJAILBIN ${FIREJAILARGS[*]} --dns=$IPHOST --netns=$NAME $*"
fi
else #or without
ip netns exec "$NAME" \
Expand Down

0 comments on commit f32fb25

Please sign in to comment.