From 279f606d9e9c094bd1a46843368fbcff6a63d9f4 Mon Sep 17 00:00:00 2001 From: Tails developers Date: Wed, 24 Sep 2014 15:41:39 +0200 Subject: [PATCH] Set the TBB installation paths in its own shell library. --- config/chroot_local-hooks/10-tbb | 16 +++++++--------- .../12-remove_unwanted_browser_searchplugins | 5 ++++- .../14-add_localized_browser_searchplugins | 9 ++++++--- .../chroot_local-includes/usr/bin/tor-launcher | 5 ++++- .../usr/local/bin/getTorBrowserUserAgent | 5 ++++- .../usr/local/bin/tor-browser | 5 ++++- .../local/lib/tails-shell-library/tor-browser.sh | 5 +++++ .../usr/local/sbin/tails-prepare-win8-theme | 7 +++++-- .../usr/local/sbin/unsafe-browser | 15 +++++++++------ 9 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 config/chroot_local-includes/usr/local/lib/tails-shell-library/tor-browser.sh diff --git a/config/chroot_local-hooks/10-tbb b/config/chroot_local-hooks/10-tbb index d86168718f..f7707b7ffd 100644 --- a/config/chroot_local-hooks/10-tbb +++ b/config/chroot_local-hooks/10-tbb @@ -32,15 +32,13 @@ VERSION="$(echo "${MAIN_BUNDLE}" | sed 's/tor-browser-linux32-\(.*\)_en-US.tar.x #TBB_DIST_URL="http://www.torproject.org/dist/torbrowser/${VERSION}/" TBB_DIST_URL="http://people.torproject.org/~mikeperry/builds/${VERSION}/" -# Later we're gonna split TBB's actual browser (binaries etc), user -# data and extension into these folders, respectively. While this -# differs from how the TBB organizes the files, the end result will be -# the same, and it's practical since when creating a new browser -# profile we can simply copy the profile directory without duplicating -# all extensions. -TBB_INSTALL=/usr/local/lib/tor-browser -TBB_PROFILE=/etc/tor-browser/profile -TBB_EXT="${TBB_INSTALL}/extensions" +# Import the TBB_INSTALL, TBB_PROFILE and TBB_EXT variables, which +# contains the paths we will split TBB's actual browser (binaries +# etc), user data and extension into. While this differs from how the +# TBB organizes the files, the end result will be the same, and it's +# practical since when creating a new browser profile we can simply +# copy the profile directory without duplicating all extensions. +. /usr/local/lib/tails-shell-library/tor-browser.sh mkdir -p "${TBB_INSTALL}" "${TBB_PROFILE}" "${TBB_EXT}" # Use the builder's caching APT proxy, if any diff --git a/config/chroot_local-hooks/12-remove_unwanted_browser_searchplugins b/config/chroot_local-hooks/12-remove_unwanted_browser_searchplugins index c35d1491b4..e6d1548869 100755 --- a/config/chroot_local-hooks/12-remove_unwanted_browser_searchplugins +++ b/config/chroot_local-hooks/12-remove_unwanted_browser_searchplugins @@ -6,7 +6,10 @@ set -e echo "Removing unwanted iceweasel search plugins" -PLUGIN_DIR=/usr/local/lib/tor-browser/Browser/browser/searchplugins +# Import the TBB_INSTALL variable +. /usr/local/lib/tails-shell-library/tor-browser.sh + +PLUGIN_DIR="${TBB_INSTALL}"/Browser/browser/searchplugins rm "${PLUGIN_DIR}"/amazon*.xml rm "${PLUGIN_DIR}"/bing*.xml rm "${PLUGIN_DIR}"/eBay*.xml diff --git a/config/chroot_local-hooks/14-add_localized_browser_searchplugins b/config/chroot_local-hooks/14-add_localized_browser_searchplugins index 4a2c6523e6..cac4905266 100644 --- a/config/chroot_local-hooks/14-add_localized_browser_searchplugins +++ b/config/chroot_local-hooks/14-add_localized_browser_searchplugins @@ -9,11 +9,14 @@ echo "Setting up localized browser search plugins" # linked in '/etc/tor-browser/profile/searchplugins/locale/es-AR', # '/etc/tor-browser/profile/searchplugins/locale/es-ES', etc. +# Import the TBB_INSTALL and TBB_EXT variables +. /usr/local/lib/tails-shell-library/tor-browser.sh + locales_for_lang() { local locale="$1" local langpacks - find /usr/local/lib/tor-browser/extensions -maxdepth 1 -type f -name 'langpack-*@firefox.mozilla.org.xpi' -printf "%P\n" | + find "${TBB_EXT}" -maxdepth 1 -type f -name 'langpack-*@firefox.mozilla.org.xpi' -printf "%P\n" | sed -n -e "s/^langpack-\($locale\)\(-[A-Z]\+\)\?@firefox.mozilla.org.xpi/\1\2/p" } @@ -24,9 +27,9 @@ for LANGUAGE in $(find /usr/share/amnesia/browser/searchplugins/locale -maxdepth exit 1 fi for LOCALE in $LOCALES; do - mkdir -p /usr/local/lib/tor-browser/Browser/distribution/searchplugins/locale/$LOCALE + mkdir -p "${TBB_INSTALL}"/Browser/distribution/searchplugins/locale/$LOCALE for SEARCHPLUGIN in $(find "/usr/share/amnesia/browser/searchplugins/locale/$LANGUAGE" -maxdepth 1 -type f); do - ln -s "$SEARCHPLUGIN" /usr/local/lib/tor-browser/Browser/distribution/searchplugins/locale/$LOCALE + ln -s "$SEARCHPLUGIN" "${TBB_INSTALL}"/Browser/distribution/searchplugins/locale/$LOCALE done done done diff --git a/config/chroot_local-includes/usr/bin/tor-launcher b/config/chroot_local-includes/usr/bin/tor-launcher index 35d721e780..66079667d8 100755 --- a/config/chroot_local-includes/usr/bin/tor-launcher +++ b/config/chroot_local-includes/usr/bin/tor-launcher @@ -2,6 +2,9 @@ set -e +# Import the TBB_INSTALL variable +. /usr/local/lib/tails-shell-library/tor-browser.sh + # The Tor Browser hardcodes the default profile dir to ../.. from the # folder storing the application.ini file supplied via -app. Sadly, # -profile doesn't work together with -app. Therefore we copy the @@ -24,4 +27,4 @@ EOF ln -s /var/lib/tails-user-session/browser-locale.js \ "${HOME}"/.tor-launcher/TorBrowser/Data/Browser/profile.default/preferences/locale.js fi -/usr/local/lib/tor-browser/Browser/firefox --app "${HOME}"/.tor-launcher/tor-launcher-standalone/application.ini +exec "${TBB_INSTALL}"/Browser/firefox --app "${HOME}"/.tor-launcher/tor-launcher-standalone/application.ini diff --git a/config/chroot_local-includes/usr/local/bin/getTorBrowserUserAgent b/config/chroot_local-includes/usr/local/bin/getTorBrowserUserAgent index 63ea5c6e93..ad530625e5 100755 --- a/config/chroot_local-includes/usr/local/bin/getTorBrowserUserAgent +++ b/config/chroot_local-includes/usr/local/bin/getTorBrowserUserAgent @@ -1,5 +1,8 @@ #!/bin/sh -unzip -q -p /usr/local/lib/tor-browser/Browser/browser/omni.ja \ +# Import the TBB_INSTALL variable +. /usr/local/lib/tails-shell-library/tor-browser.sh + +unzip -q -p "${TBB_INSTALL}"/Browser/browser/omni.ja \ defaults/preferences/000-tor-browser.js | \ sed -n 's@^pref("general\.useragent\.override", "\(.*\)");$@\1@p' diff --git a/config/chroot_local-includes/usr/local/bin/tor-browser b/config/chroot_local-includes/usr/local/bin/tor-browser index 0490c015a9..9e469152ae 100644 --- a/config/chroot_local-includes/usr/local/bin/tor-browser +++ b/config/chroot_local-includes/usr/local/bin/tor-browser @@ -11,6 +11,9 @@ export TEXTDOMAIN PROFILE="${HOME}/.tor-browser/profile.default" +# Import the TBB_INSTALL variable +. /usr/local/lib/tails-shell-library/tor-browser.sh + ask_for_confirmation() { local dialog_title="`gettext \"Tor is not ready\"`" local dialog_text="`gettext \"Tor is not ready. Start Tor Browser anyway?\"`" @@ -40,7 +43,7 @@ start_browser() { unset SESSION_MANAGER - exec /usr/local/lib/tor-browser/Browser/firefox -no-remote --class "Tor Browser" -profile "${PROFILE}" "${@}" + exec "${TBB_INSTALL}"/Browser/firefox -no-remote --class "Tor Browser" -profile "${PROFILE}" "${@}" } diff --git a/config/chroot_local-includes/usr/local/lib/tails-shell-library/tor-browser.sh b/config/chroot_local-includes/usr/local/lib/tails-shell-library/tor-browser.sh new file mode 100644 index 0000000000..9c52d23b69 --- /dev/null +++ b/config/chroot_local-includes/usr/local/lib/tails-shell-library/tor-browser.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +TBB_INSTALL=/usr/local/lib/tor-browser +TBB_PROFILE=/etc/tor-browser/profile +TBB_EXT="${TBB_INSTALL}/extensions" diff --git a/config/chroot_local-includes/usr/local/sbin/tails-prepare-win8-theme b/config/chroot_local-includes/usr/local/sbin/tails-prepare-win8-theme index d04687496c..87a2df0628 100755 --- a/config/chroot_local-includes/usr/local/sbin/tails-prepare-win8-theme +++ b/config/chroot_local-includes/usr/local/sbin/tails-prepare-win8-theme @@ -4,6 +4,9 @@ # be run as the desktop user. It consists mainly of ugly workarounds. Running this # script will change the system until next reboot. +# Import the TBB_INSTALL variable +. /usr/local/lib/tails-shell-library/tor-browser.sh + # Activate the camouflage for the next session install -m 0644 \ /usr/share/applications/tails-activate-win8-theme.desktop \ @@ -17,8 +20,8 @@ for icon in /usr/share/icons/hicolor/*/apps/pidgin.png; do done # Set Tor Browser application icon -for icon in /usr/local/lib/tor-browser/Browser/browser/chrome/icons/default/*.png \ - /usr/local/lib/tor-browser/Browser/browser/icons/*.png; do +for icon in "${TBB_INSTALL}"/Browser/browser/chrome/icons/default/*.png \ + "${TBB_INSTALL}"/Browser/browser/icons/*.png; do rm "$icon" ln -s "/usr/share/icons/Windows8/apps/iceweasel.png" "$icon" done diff --git a/config/chroot_local-includes/usr/local/sbin/unsafe-browser b/config/chroot_local-includes/usr/local/sbin/unsafe-browser index 2674dc95d7..ab75ad530a 100755 --- a/config/chroot_local-includes/usr/local/sbin/unsafe-browser +++ b/config/chroot_local-includes/usr/local/sbin/unsafe-browser @@ -18,6 +18,9 @@ CLEARNET_USER=clearnet # Import tor_is_working() . /usr/local/lib/tails-shell-library/tor.sh +# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables +. /usr/local/lib/tails-shell-library/tor-browser.sh + WARNING_PAGE='/usr/share/doc/tails/website/misc/unsafe_browser_warning' LANG_CODE="$(echo ${LANG} | head -c 2)" if [ -r "${WARNING_PAGE}.${LANG_CODE}.html" ]; then @@ -108,7 +111,7 @@ set_chroot_browser_name () { NAME="${1}" LONG=$(echo ${LANG} | grep -o "^[a-zA-Z_]*") SHORT=${LONG%%_*} - EXT_DIR=${CHROOT}/usr/local/lib/tor-browser/extensions + EXT_DIR=${CHROOT}/"${TBB_EXT}" BRANDING=branding/brand.dtd if [ -e "${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi" ]; then PACK="${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi" @@ -119,7 +122,7 @@ set_chroot_browser_name () { TOP=browser/chrome REST=${SHORT}/locale else - PACK="${CHROOT}/usr/local/lib/tor-browser/Browser/browser/omni.ja" + PACK="${CHROOT}/"${TBB_EXT}"/Browser/browser/omni.ja" TOP=chrome REST=en-US/locale fi @@ -156,8 +159,8 @@ configure_chroot () { CLEARNET_EXT="${CLEARNET_PROFILE}"/extensions mkdir -p "${CLEARNET_EXT}" - cp -Pr /etc/tor-browser/profile/extensions/langpack-*.xpi \ - /etc/tor-browser/profile/extensions/branding@amnesia.boum.org \ + cp -Pr "${TBB_PROFILE}"/extensions/langpack-*.xpi \ + "${TBB_PROFILE}"/extensions/branding@amnesia.boum.org \ "${CLEARNET_EXT}" CLEARNET_PREFS="${CLEARNET_PROFILE}"/preferences/prefs.js @@ -178,7 +181,7 @@ configure_chroot () { "${CLEARNET_PREFS}" # Remove all bookmarks - rm -f ${CHROOT}/etc/tor-browser/default.profile/bookmarks.html + rm -f ${CHROOT}/"${TBB_PROFILE}"/bookmarks.html rm -f ${CLEARNET_PROFILE}/bookmarks.html rm -f ${CLEARNET_PROFILE}/places.sqlite @@ -206,7 +209,7 @@ run_browser_in_chroot () { echo "* Starting Unsafe Browser" sudo -u ${SUDO_USER} xhost +SI:localuser:${CLEARNET_USER} 2>/dev/null - chroot ${CHROOT} sudo -u ${CLEARNET_USER} /usr/local/lib/tor-browser/Browser/firefox -DISPLAY=:0.0 -profile /home/clearnet/.tor-browser/profile.default + chroot ${CHROOT} sudo -u ${CLEARNET_USER} "${TBB_INSTALL}"/Browser/firefox -DISPLAY=:0.0 -profile /home/clearnet/.tor-browser/profile.default sudo -u ${SUDO_USER} xhost -SI:localuser:${CLEARNET_USER} 2>/dev/null } -- GitLab