Commit f55763c7 authored by Tails developers's avatar Tails developers

Refactor further, renaming a few functions (for clarity) along the way.

parent 0cef488b
......@@ -31,7 +31,7 @@ try_cleanup_browser_chroot () {
}
# Setup a chroot on a clean aufs "fork" of the root filesystem.
setup_browser_chroot () {
setup_chroot_for_browser () {
local chroot="${1}"
local cow="${2}"
local user="${3}"
......@@ -90,8 +90,8 @@ set_chroot_browser_locale () {
configure_xulrunner_app_locale "${browser_profile}" "${locale}"
}
# Must be called after configure_chroot_browser(), since it depends on
# which extensions are installed in the profile.
# Must be called after configure_chroot_browser_profile(), since it
# depends on which extensions are installed in the profile.
set_chroot_browser_name () {
local chroot="${1}"
local human_readable_name="${2}"
......@@ -170,7 +170,7 @@ set_chroot_browser_permissions () {
chown -R "${browser_user}:${browser_user}" "${browser_conf}"
}
configure_chroot_browser () {
configure_chroot_browser_profile () {
local chroot="${1}" ; shift
local browser_name="${1}" ; shift
local browser_user="${1}" ; shift
......@@ -226,3 +226,25 @@ configure_chroot_browser () {
chroot "${chroot}" sudo -H -u "${browser_user}" sh -c 'eval `dbus-launch --auto-syntax`; tails-activate-win8-theme' || :
fi
}
configure_chroot_browser () {
local chroot="${1}" ; shift
local browser_user="${1}" ; shift
local browser_name="${1}" ; shift
local human_readable_name="${1}" ; shift
local home_page="${1}" ; shift
local dns_servers="${1}" ; shift
# Now $@ is a list of paths (that must be valid after chrooting)
# to extensions to enable.
local best_locale="$(guess_best_tor_browser_locale)"
configure_chroot_dns_servers "${chroot}" "${dns_servers}"
configure_chroot_browser_profile "${chroot}" "${browser_name}" \
"${browser_user}" "${home_page}" "${@}"
set_chroot_browser_locale "${chroot}" "${browser_name}" "${browser_user}" \
"${best_locale}"
set_chroot_browser_name "${chroot}" "${human_readable_name}" \
"${browser_name}" "${browser_user}" "${best_locale}"
set_chroot_browser_permissions "${chroot}" "${browser_name}" \
"${browser_user}"
}
......@@ -92,7 +92,7 @@ HOME_PAGE="http://127.0.0.1:7657"
NOSCRIPT_EXT_XPI="${TBB_EXT}/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
TORBUTTON_EXT_DIR="${TBB_EXT}/torbutton@torproject.org"
HUMAN_READABLE_NAME="`gettext \"I2P Browser\"`"
BEST_LOCALE="$(guess_best_tor_browser_locale)"
IP4_NAMESERVERS="0.0.0.0"
# Prevent multiple instances of the script.
exec 9>"${LOCK}"
......@@ -106,21 +106,14 @@ fi
show_start_notification
echo "* Setting up chroot"
setup_browser_chroot "${CHROOT}" "${COW}" "${BROWSER_USER}" || \
setup_chroot_for_browser "${CHROOT}" "${COW}" "${BROWSER_USER}" || \
error "`gettext \"Failed to setup chroot.\"`"
echo "* Configuring chroot"
configure_chroot_dns_servers "${CHROOT}" "0.0.0.0"
configure_chroot_browser "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" \
"${HOME_PAGE}" "${TBB_EXT}"/langpack-*.xpi \
"${NOSCRIPT_EXT_XPI}" "${TORBUTTON_EXT_DIR}" && \
copy_extra_tbb_prefs "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" && \
set_chroot_browser_locale "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" \
"${BEST_LOCALE}" && \
set_chroot_browser_name "${CHROOT}" "${HUMAN_READABLE_NAME}" "${BROWSER_NAME}" \
"${BROWSER_USER}" "${BEST_LOCALE}" && \
set_chroot_browser_permissions "${CHROOT}" "${BROWSER_NAME}" \
"${BROWSER_USER}" || \
configure_chroot_browser "${CHROOT}" "${BROWSER_USER}" "${BROWSER_NAME}" \
"${HUMAN_READABLE_NAME}" "${HOME_PAGE}" "${IP4_NAMESERVERS}" \
"${TBB_EXT}"/langpack-*.xpi "${NOSCRIPT_EXT_XPI}" "${TORBUTTON_EXT_DIR}" && \
copy_extra_tbb_prefs "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" || \
error "`gettext \"Failed to configure browser.\"`"
echo "* Starting I2P Browser"
......
......@@ -84,7 +84,6 @@ BROWSER_NAME="unsafe-browser"
BROWSER_USER="clearnet"
HUMAN_READABLE_NAME="`gettext \"Unsafe Browser\"`"
NM_ENV_FILE="/var/lib/NetworkManager/env"
BEST_LOCALE="$(guess_best_tor_browser_locale)"
WARNING_PAGE='/usr/share/doc/tails/website/misc/unsafe_browser_warning'
HOME_PAGE="$(localized_tails_doc_page "${WARNING_PAGE}")"
......@@ -120,19 +119,13 @@ verify_start
show_start_notification
echo "* Setting up chroot"
setup_browser_chroot "${CHROOT}" "${COW}" "${BROWSER_USER}" || \
setup_chroot_for_browser "${CHROOT}" "${COW}" "${BROWSER_USER}" || \
error "`gettext \"Failed to setup chroot.\"`"
echo "* Configuring chroot"
configure_chroot_dns_servers "${CHROOT}" "${IP4_NAMESERVERS}" && \
configure_chroot_browser "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" \
"${HOME_PAGE}" "${TBB_EXT}"/langpack-*.xpi && \
set_chroot_browser_locale "${CHROOT}" "${BROWSER_NAME}" "${BROWSER_USER}" \
"${BEST_LOCALE}" && \
set_chroot_browser_name "${CHROOT}" "${HUMAN_READABLE_NAME}" "${BROWSER_NAME}" \
"${BROWSER_USER}" "${BEST_LOCALE}" && \
set_chroot_browser_permissions "${CHROOT}" "${BROWSER_NAME}" \
"${BROWSER_USER}" || \
configure_chroot_browser "${CHROOT}" "${BROWSER_USER}" "${BROWSER_NAME}" \
"${HUMAN_READABLE_NAME}" "${HOME_PAGE}" "${IP4_NAMESERVERS}" \
"${TBB_EXT}"/langpack-*.xpi || \
error "`gettext \"Failed to configure browser.\"`"
echo "* Starting Unsafe Browser"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment