2020-05-21 15:11:31 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
HERE="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
|
|
JAIL_HOME=/home/proton
|
2020-05-22 22:31:37 +00:00
|
|
|
BIN="${BIN:-entrypoint.sh}"
|
|
|
|
|
2020-05-22 23:14:50 +00:00
|
|
|
if [[ -z "${BRIDGE_HOME:-}" ]]; then
|
|
|
|
echo "Please set the BRIDGE_HOME envvar!"
|
2020-05-22 22:31:37 +00:00
|
|
|
exit 1
|
|
|
|
else
|
2020-05-22 23:14:50 +00:00
|
|
|
BRIDGE_HOME="$(realpath "${BRIDGE_HOME}")"
|
2020-05-22 22:31:37 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-23 01:24:28 +00:00
|
|
|
exec nsjail -Mo \
|
2020-05-21 15:11:31 +00:00
|
|
|
--disable_clone_newnet \
|
2020-05-26 16:23:20 +00:00
|
|
|
--disable_rlimits \
|
2020-05-21 15:11:31 +00:00
|
|
|
--cwd "${JAIL_HOME}" \
|
|
|
|
--tmpfsmount /tmp --tmpfsmount /run \
|
2020-05-22 23:14:50 +00:00
|
|
|
--bindmount "${BRIDGE_HOME}:${JAIL_HOME}" \
|
2020-05-22 13:35:24 +00:00
|
|
|
--symlink /proc/self/fd:/dev/fd \
|
2020-05-21 15:11:31 +00:00
|
|
|
--bindmount_ro "${HERE}/entrypoint.sh:${JAIL_HOME}/entrypoint.sh" \
|
|
|
|
--bindmount_ro "${HERE}/gpg-keygen-params.txt:${JAIL_HOME}/gpg-keygen-params.txt" \
|
|
|
|
--bindmount_ro /bin --bindmount_ro /sbin \
|
|
|
|
--bindmount_ro /usr --bindmount_ro /lib --bindmount_ro /lib64 \
|
|
|
|
--bindmount_ro /dev/null --bindmount_ro /dev/urandom --bindmount_ro /dev/random \
|
2020-05-22 13:34:40 +00:00
|
|
|
--bindmount_ro /etc/resolv.conf \
|
2020-05-21 15:11:31 +00:00
|
|
|
--env HOME=/home/proton \
|
|
|
|
--env PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin \
|
2020-05-22 21:26:34 +00:00
|
|
|
--env BRIDGE_USER \
|
|
|
|
--env BRIDGE_PASS \
|
2020-05-22 22:31:37 +00:00
|
|
|
-- ${BIN} "${1:-}"
|
2020-05-21 15:11:31 +00:00
|
|
|
|