Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tor Browser support #43

Merged
merged 6 commits into from Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions etc/sandbox-app-launcher/torbrowser.conf
@@ -0,0 +1,8 @@
## Copyright (C) 2012 - 2020 ENCRYPTED SUPPORT LP <adrelanos@riseup.net>
## See the file COPYING for copying conditions.

allow_net=yes
allow_webcam=yes
allow_mic=yes
shared_storage=read-write
allow_dynamic_native_code_exec=yes
29 changes: 25 additions & 4 deletions usr/bin/sandbox-app-launcher
Expand Up @@ -9,9 +9,11 @@ app_name="${1}"
shift 1
: ${app_path:="$(type -P "${app_name}" || true)"}

if ! [[ "${app_name}" =~ [0-9a-zA-Z/] ]] || ! [[ "${app_path}" =~ [0-9a-zA-Z/] ]]; then
echo "ERROR: Invalid character."
exit 1
if ! [[ "${app_name}" =~ [0-9a-zA-Z/] ]]; then
if ! [[ "${app_path}" =~ [0-9a-zA-Z/] ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The should not be a nested if. No need. app_name could be OK while app_path is not.

Will add a commit on top to fix.

echo "ERROR: Invalid character."
exit 1
fi
fi

main_app_dir="/usr/share/sandbox-app-launcher"
Expand All @@ -26,6 +28,10 @@ wx_whitelist="${main_app_dir}/wx_whitelist"
shared_dir="${appdata_dir}/shared"
bwrap_args=""

if [ "${app_name}" = "torbrowser" ]; then
app_path="${app_homedir}/.tb/tor-browser/Browser/start-tor-browser"
fi

error_handler() {
echo "
## sandbox-app-launcher BUG.
Expand All @@ -47,7 +53,7 @@ if [ -f "/etc/sandbox-app-launcher/${app_name}.conf" ]; then
fi

setup() {
if ! [ -x "${app_path}" ]; then
if ! [ -x "${app_path}" ] && ! [ "${app_name}" = "torbrowser" ]; then
echo "ERROR: Could not find '${app_name}' in \$PATH."
exit 1
fi
Expand Down Expand Up @@ -131,6 +137,11 @@ setup() {
if ! [ -e "${wrapper_dir}/${app_name}" ]; then
cat <<EOF > "${wrapper_dir}/${app_name}"
#!/bin/bash

if [ -x /etc/X11/Xsession.d/20torbrowser ]; then
source /etc/X11/Xsession.d/20torbrowser
fi

dbus-launch
"${app_path}" "\${@}"
EOF
Expand Down Expand Up @@ -171,6 +182,14 @@ run_program() {
bwrap_args+="--ro-bind ${shared_dir} ${shared_dir} --ro-bind /shared /shared "
fi

## Install Tor Browser.
if [ "${app_name}" = "torbrowser" ]; then
if ! [ -d "${app_homedir}/.tb" ]; then
echo -e "INFO: Installing Tor Browser in sandbox...\n"
sudo -H -u "${app_user}" bash -c "tb_skip_functions+=' remount_exec tb_start_tor_browser ' torbrowser"
fi
fi

sudo -H -u "${app_user}" bash -c "
bwrap \
--ro-bind /bin /bin \
Expand Down Expand Up @@ -204,6 +223,8 @@ run_program() {
--ro-bind ${app_path} ${app_path} \
--tmpfs /run \
--symlink /run /var/run \
--ro-bind-try /run/anon-ws-disable-stacked-tor/127.0.0.1_9150.sock /run/anon-ws-disable-stacked-tor/127.0.0.1_9150.sock \
--ro-bind-try /run/anon-ws-disable-stacked-tor/127.0.0.1_9151.sock /run/anon-ws-disable-stacked-tor/127.0.0.1_9151.sock \
--dev /dev \
--chdir ${app_homedir} \
--setenv HOME ${app_homedir} \
Expand Down