Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions usr/bin/sandbox-app-launcher
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,49 @@
## Copyright (C) 2012 - 2020 ENCRYPTED SUPPORT LP <adrelanos@riseup.net>
## See the file COPYING for copying conditions.

set -e

main_app_dir="/usr/share/sandbox-app-launcher"
auto_dir="/var/cache/sandbox-app-launcher-autogenerated"
symlink_dir="${auto_dir}/symlinks"
appdata_dir="/home/sandbox-app-launcher-appdata"
app_name="${*}"
app_name="${1}"
shift 1
app_user="sandbox-${app_name}"
app_homedir="${appdata_dir}/${app_name}"
app_path="$(type -P ${app_name})"
app_path="$(type -P "${app_name}")"
seccomp_filter="${auto_dir}/seccomp-filter.bpf"
wx_whitelist="${main_app_dir}/wx_whitelist"
shared_dir="/shared"
bwrap_args=""

error_handler() {
echo "
## sandbox-app-launcher BUG.
## BASH_COMMAND: ${BASH_COMMAND}
## Please report this BUG!
"
exit 1
}

trap "error_handler" ERR

if ! [ "$(id -u)" = "0" ]; then
echo "ERROR: Must run as root."
exit 1
fi

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

if [ -f "/etc/sandbox-app-launcher/${app_name}.conf" ]; then
. "/etc/sandbox-app-launcher/${app_name}.conf"
fi

setup() {
if ! [[ "${app_name}" =~ [0-9a-zA-Z/] ]]; then
echo "ERROR: Invalid character."
exit 1
fi

if ! [ -e "${app_path}" ]; then
if ! [ -x "${app_path}" ]; then
echo "ERROR: Could not find '${app_name}' in \$PATH."
exit 1
fi
Expand Down Expand Up @@ -55,7 +74,7 @@ setup() {
useradd -m -d "${app_homedir}" -s /sbin/nologin "${app_user}"
fi

if ! [ "$(stat -c %a ${app_homedir})" = "700" ]; then
if ! [ "$(stat -c %a "${app_homedir}")" = "700" ]; then
chmod 700 -R "${app_homedir}"
fi

Expand Down Expand Up @@ -183,7 +202,7 @@ run_program() {
11< <(getent group root ${app_user} nobody) \
12< ${seccomp_filter} \
${bwrap_args} \
${symlink_dir}/${app_name}"
${symlink_dir}/${app_name} ${@}"
}

setup
Expand Down