Commit 73b77998 authored by Kathleen Brade's avatar Kathleen Brade Committed by Georg Koppen
Browse files

Bug 13252 - Do not store data in the app bundle

Add an --enable-tor-browser-data-outside-app-dir configure option.
When this is enabled, all user data is stored in a directory named
TorBrowser-Data which is located next to the application directory.

The first time an updated browser is opened, migrate the existing
browser profile, Tor data directory contents, and UpdateInfo to the
TorBrowser-Data directory. If migration of the browser profile
fails, an error alert is displayed and the browser is started
using a new profile.

Display an informative error messages if the TorBrowser-Data
directory cannot be created due to an "access denied" or a
"read only volume" error.

Add support for installing "override" preferences within the user's
browser profile. All .js files in distribution/preferences (on
Mac OS, Contents/Resources/distribution/preferences) will be copied
to the preferences directory within the user's browser profile when
the profile is created and each time Tor Browser is updated. This
mechanism will be used to install the extension-overrides.js file
into the profile.

On Mac OS, add support for the --invisible command line option which
is used by the meek-http-helper to avoid showing an icon for the
helper browser on the dock.
parent ea8fc6ac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ ac_add_options --enable-official-branding
ac_add_options --enable-optimize
ac_add_options --disable-debug

ac_add_options --enable-tor-browser-data-outside-app-dir
ac_add_options --enable-tor-browser-update
ac_add_options --enable-update-packaging
ac_add_options --enable-signmar
+11 −0
Original line number Diff line number Diff line
@@ -6538,9 +6538,20 @@ if test -n "$TOR_BROWSER_UPDATE"; then
    AC_DEFINE(TOR_BROWSER_UPDATE)
fi

MOZ_ARG_ENABLE_BOOL(tor-browser-data-outside-app-dir,
[  --enable-tor-browser-data-outside-app-dir
                          Enable Tor Browser data outside of app directory],
    TOR_BROWSER_DATA_OUTSIDE_APP_DIR=1,
    TOR_BROWSER_DATA_OUTSIDE_APP_DIR= )

if test -n "$TOR_BROWSER_DATA_OUTSIDE_APP_DIR"; then
    AC_DEFINE(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)
fi

AC_DEFINE_UNQUOTED(TOR_BROWSER_VERSION,"$TOR_BROWSER_VERSION")
AC_SUBST(TOR_BROWSER_VERSION)
AC_SUBST(TOR_BROWSER_UPDATE)
AC_SUBST(TOR_BROWSER_DATA_OUTSIDE_APP_DIR)

dnl ========================================================
dnl build the tests by default
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ profileProblemTitle=%S Profile Problem
profileReadOnly=You cannot run %S from a read-only file system.  Please copy %S to another location before trying to use it.
profileReadOnlyMac=You cannot run %S from a read-only file system.  Please copy %S to your Desktop or Applications folder before trying to use it.
profileAccessDenied=%S does not have permission to access the profile. Please adjust your file system permissions and try again.
profileMigrationFailed=Migration of your existing %S profile failed.\nNew settings will be used.
# Profile manager
# LOCALIZATION NOTE (profileTooltip): First %S is the profile name, second %S is the path to the profile folder.
profileTooltip=Profile: '%S' - Path: '%S'
+29 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE            = "general.useragent.locale";
const UNKNOWN_XPCOM_ABI               = "unknownABI";

#ifdef TOR_BROWSER_VERSION
#expand const TOR_BROWSER_VERSION = __TOR_BROWSER_VERSION__;
const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
#endif

const PREF_MIN_WEBEXT_PLATFORM_VERSION = "extensions.webExtensionsMinPlatformVersion";

const UPDATE_REQUEST_VERSION          = 2;
@@ -910,6 +915,30 @@ var AddonManagerInternal = {
        this.validateBlocklist();
      }

#ifdef TOR_BROWSER_VERSION
      // To ensure that extension override prefs are reinstalled into the
      // user's profile after each update, set appChanged = true if the
      // Mozilla app version has not changed but the Tor Browser version
      // has changed.
      let tbChanged = undefined;
      try {
        tbChanged = TOR_BROWSER_VERSION !=
                   Services.prefs.getCharPref(PREF_EM_LAST_TORBROWSER_VERSION);
      }
      catch (e) { }
      if (tbChanged !== false) {
        // Because PREF_EM_LAST_TORBROWSER_VERSION was not present in older
        // versions of Tor Browser, an app change is indicated when tbChanged
        // is undefined or true.
        if (appChanged === false) {
          appChanged = true;
        }

        Services.prefs.setCharPref(PREF_EM_LAST_TORBROWSER_VERSION,
                                   TOR_BROWSER_VERSION);
      }
#endif

      if (!MOZ_COMPATIBILITY_NIGHTLY) {
        PREF_EM_CHECK_COMPATIBILITY = PREF_EM_CHECK_COMPATIBILITY_BASE + "." +
                                      Services.appinfo.version.replace(BRANCH_REGEXP, "$1");
+59 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/exte
const STRING_TYPE_NAME                = "type.%ID%.name";

const DIR_EXTENSIONS                  = "extensions";
const DIR_PREFERENCES                 = "preferences";
const DIR_SYSTEM_ADDONS               = "features";
const DIR_STAGE                       = "staged";
const DIR_TRASH                       = "trash";
@@ -3510,6 +3511,58 @@ this.XPIProvider = {
    return changed;
  },

   /**
   * Installs any preference files located in the preferences directory of the
   * application's distribution specific directory into the profile.
   *
   * @return true if any preference files were installed
   */
  installDistributionPreferences: function XPI_installDistributionPreferences() {
    let distroDir;
    try {
      distroDir = FileUtils.getDir(KEY_APP_DISTRIBUTION, [DIR_PREFERENCES]);
    }
    catch (e) {
      return false;
    }

    if (!distroDir.exists() || !distroDir.isDirectory())
      return false;

    let changed = false;
    let prefOverrideDir = Services.dirsvc.get("PrefDOverride", Ci.nsIFile);

    let entries = distroDir.directoryEntries
                           .QueryInterface(Ci.nsIDirectoryEnumerator);
    let entry;
    while ((entry = entries.nextFile)) {
      let fileName = entry.leafName;
      if (!entry.isFile() ||
          fileName.substring(fileName.length - 3).toLowerCase() != ".js") {
        logger.debug("Ignoring distribution preference that isn't a JS file: "
                     + entry.path);
        continue;
      }

      try {
        if (!prefOverrideDir.exists()) {
          prefOverrideDir.create(Ci.nsIFile.DIRECTORY_TYPE,
                                 FileUtils.PERMS_DIRECTORY);
        }

        entry.copyTo(prefOverrideDir, null);
        changed = true;
      } catch (e) {
        logger.debug("Unable to copy " + entry.path + " to " +
                     prefOverrideDir.path);
      }
    }

    entries.close();

    return changed;
  },

  /**
   * Imports the xpinstall permissions from preferences into the permissions
   * manager for the user to change later.
@@ -3583,6 +3636,12 @@ this.XPIProvider = {
      if (updated) {
        updateReasons.push("installDistributionAddons");
      }

      // Also copy distribution preferences to the user's profile.
      updated = this.installDistributionPreferences();
      if (updated) {
        updateReasons.push("installDistributionPreferences");
      }
    }

    // Telemetry probe added around getInstallState() to check perf
Loading