Commit ffb33c63 authored by Kathleen Brade's avatar Kathleen Brade Committed by Matthew Finkel
Browse files

Bug 4234: Use the Firefox Update Process for Tor Browser.

The following files are never updated:
  TorBrowser/Data/Browser/profiles.ini
  TorBrowser/Data/Browser/profile.default/bookmarks.html
  TorBrowser/Data/Tor/torrc
Mac OS: Store update metadata under TorBrowser/UpdateInfo.
Removed the %OS_VERSION% component from the update URL (13047) and
  added support for minSupportedOSVersion, an attribute of the
  <update> element that may be used to trigger Firefox's
  "unsupported platform" behavior.
Hide the "What's new" links (set app.releaseNotesURL value to about:blank).
Windows: disable "runas" code path in updater (15201).
Windows: avoid writing to the registry (16236).
Also includes fixes for tickets 13047, 13301, 13356, 13594, 15406,
  16014, 16909, 24476, and 25909.

Also fix Bug 26049: reduce the delay before the update prompt is displayed.
Instead of Firefox's 2 days, we use 1 hour (after which time the update
doorhanger will be displayed).

Also fix bug 27221: purge the startup cache if the Tor Browser
version changed (even if the Firefox version and build ID did
not change), e.g., after a minor Tor Browser update.

Also fix 32616: Disable GetSecureOutputDirectoryPath() functionality.

Bug 26048: potentially confusing "restart to update" message

Within the update doorhanger, remove the misleading message that mentions
that windows will be restored after an update is applied, and replace the
"Restart and Restore" button label with an existing
"Restart to update Tor Browser" string.

Bug 28885: notify users that update is downloading

Add a "Downloading Tor Browser update" item which appears in the
hamburger (app) menu while the update service is downloading a MAR
file. Before this change, the browser did not indicate to the user
that an update was in progress, which is especially confusing in
Tor Browser because downloads often take some time. If the user
clicks on the new menu item, the about dialog is opened to allow
the user to see download progress.

As part of this fix, the update service was changed to always show
update-related messages in the hamburger menu, even if the update
was started in the foreground via the about dialog or via the
"Check for Tor Browser Update" toolbar menu item. This change is
consistent with the Tor Browser goal of making sure users are
informed about the update process.

Removed #28885 parts of this patch which have been uplifted to Firefox.

Use a localized string from Torbutton for the app menu's
"Downloading update" message. This is a temporary fix that can
be removed once Tor Browser is based on Firefox 79 or newer (at
which point the localized string will be included in the Firefox
language packs).
parent 59696f4f
......@@ -98,10 +98,12 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME)
rsync -aL $(DIST)/bin/$(MOZ_APP_NAME) '$(dist_dest)/Contents/MacOS'
cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/firefox.icns '$(dist_dest)/Contents/Resources/firefox.icns'
cp -RL $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/document.icns '$(dist_dest)/Contents/Resources/document.icns'
ifndef TOR_BROWSER_UPDATE
$(MKDIR) -p '$(dist_dest)/Contents/Library/LaunchServices'
ifdef MOZ_UPDATER
mv -f '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater' '$(dist_dest)/Contents/Library/LaunchServices'
ln -s ../../../../Library/LaunchServices/org.mozilla.updater '$(dist_dest)/Contents/MacOS/updater.app/Contents/MacOS/org.mozilla.updater'
endif
endif
printf APPLTORB > '$(dist_dest)/Contents/PkgInfo'
endif
......@@ -7,7 +7,6 @@
// Disable initial homepage notifications
pref("browser.search.update", false);
pref("browser.rights.3.shown", true);
pref("browser.startup.homepage_override.mstone", "ignore");
pref("startup.homepage_welcome_url", "");
pref("startup.homepage_welcome_url.additional", "");
......@@ -20,9 +19,17 @@ pref("startup.homepage_override_url", "https://blog.torproject.org/category/tags
// Try to nag a bit more about updates: Pop up a restart dialog an hour after the initial dialog
pref("app.update.promptWaitTime", 3600);
#ifdef XP_WIN
// For now, disable staged updates on Windows (see #18292).
pref("app.update.notifyDuringDownload", true);
pref("app.update.url.manual", "https://www.torproject.org/download/languages/");
pref("app.update.url.details", "https://www.torproject.org/download/");
pref("app.update.badgeWaitTime", 0);
pref("app.releaseNotesURL", "about:blank");
#ifndef XP_MACOSX
// Disable staged updates on platforms other than macOS.
// Staged updates do not work on Windows due to #18292.
// Also, on Windows and Linux any changes that are made to the browser profile
// or Tor data after an update is staged will be lost.
pref("app.update.staging.enabled", false);
#endif
......@@ -82,6 +89,7 @@ pref("datareporting.policy.dataSubmissionEnabled", false);
// Make sure Unified Telemetry is really disabled, see: #18738.
pref("toolkit.telemetry.unified", false);
pref("toolkit.telemetry.enabled", false);
pref("toolkit.telemetry.updatePing.enabled", false); // Make sure updater telemetry is disabled; see #25909.
#ifdef XP_WIN
// Defense-in-depth: ensure that the Windows default browser agent will
// not ping Mozilla if it is somehow present (we omit it at build time).
......
......@@ -136,14 +136,8 @@ pref("app.update.elevation.promptMaxAttempts", 2);
pref("app.update.notifyDuringDownload", false);
// If set to true, the Update Service will automatically download updates if the
// user can apply updates. This pref is no longer used on Windows, except as the
// default value to migrate to the new location that this data is now stored
// (which is in a file in the update directory). Because of this, this pref
// should no longer be used directly. Instead, getAppUpdateAutoEnabled and
// getAppUpdateAutoEnabled from UpdateUtils.jsm should be used.
#ifndef XP_WIN
pref("app.update.auto", true);
#endif
// user can apply updates.
pref("app.update.auto", true);
// If set to true, the Update Service will apply updates in the background
// when it finishes downloading them.
......
......@@ -192,7 +192,7 @@ appUpdater.prototype = {
if (aChildID == "downloadAndInstall") {
let updateVersion = gAppUpdater.update.displayVersion;
// Include the build ID if this is an "a#" (nightly or aurora) build
if (/a\d+$/.test(updateVersion)) {
if (!AppConstants.TOR_BROWSER_UPDATE && /a\d+$/.test(updateVersion)) {
let buildID = gAppUpdater.update.buildID;
let year = buildID.slice(0, 4);
let month = buildID.slice(4, 6);
......
......@@ -147,7 +147,7 @@ appUpdater.prototype = {
if (aChildID == "downloadAndInstall") {
let updateVersion = gAppUpdater.update.displayVersion;
// Include the build ID if this is an "a#" (nightly or aurora) build
if (/a\d+$/.test(updateVersion)) {
if (!AppConstants.TOR_BROWSER_UPDATE && /a\d+$/.test(updateVersion)) {
let buildID = gAppUpdater.update.buildID;
let year = buildID.slice(0, 4);
let month = buildID.slice(4, 6);
......
......@@ -50,15 +50,13 @@ async function init(aEvent) {
bits: Services.appinfo.is64Bit ? 64 : 32,
};
// Adjust version text to show the Tor Browser version
versionAttributes.version = AppConstants.TOR_BROWSER_VERSION +
" (based on Mozilla Firefox " +
AppConstants.MOZ_APP_VERSION_DISPLAY + ")";
let version = Services.appinfo.version;
if (/a\d+$/.test(version)) {
versionId = "aboutDialog-version-nightly";
let buildID = Services.appinfo.appBuildID;
let year = buildID.slice(0, 4);
let month = buildID.slice(4, 6);
let day = buildID.slice(6, 8);
versionAttributes.isodate = `${year}-${month}-${day}`;
document.getElementById("experimental").hidden = false;
document.getElementById("communityDesc").hidden = true;
}
......
......@@ -46,6 +46,8 @@ XPCOMUtils.defineLazyGlobalGetters(this, [URL]);
const NEWINSTALL_PAGE = "about:newinstall";
const kTBSavedVersionPref = "browser.startup.homepage_override.torbrowser.version";
// One-time startup homepage override configurations
const ONCE_DOMAINS = ["mozilla.org", "firefox.com"];
const ONCE_PREF = "browser.startup.homepage_override.once";
......@@ -105,7 +107,8 @@ const OVERRIDE_ALTERNATE_PROFILE = 4;
* Returns:
* OVERRIDE_NEW_PROFILE if this is the first run with a new profile.
* OVERRIDE_NEW_MSTONE if this is the first run with a build with a different
* Gecko milestone (i.e. right after an upgrade).
* Gecko milestone or Tor Browser version (i.e. right
* after an upgrade).
* OVERRIDE_NEW_BUILD_ID if this is the first run with a new build ID of the
* same Gecko milestone (i.e. after a nightly upgrade).
* OVERRIDE_NONE otherwise.
......@@ -128,6 +131,11 @@ function needHomepageOverride(prefb) {
var mstone = Services.appinfo.platformVersion;
var savedTBVersion = null;
try {
savedTBVersion = prefb.getCharPref(kTBSavedVersionPref);
} catch (e) {}
var savedBuildID = prefb.getCharPref(
"browser.startup.homepage_override.buildID",
""
......@@ -146,7 +154,22 @@ function needHomepageOverride(prefb) {
prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
return savedmstone ? OVERRIDE_NEW_MSTONE : OVERRIDE_NEW_PROFILE;
prefb.setCharPref(kTBSavedVersionPref, AppConstants.TOR_BROWSER_VERSION);
// After an upgrade from an older release of Tor Browser (<= 5.5a1), the
// savedmstone will be undefined because those releases included the
// value "ignore" for the browser.startup.homepage_override.mstone pref.
// To correctly detect an upgrade vs. a new profile, we check for the
// presence of the "app.update.postupdate" pref.
let updated = prefb.prefHasUserValue("app.update.postupdate");
return (savedmstone || updated) ? OVERRIDE_NEW_MSTONE
: OVERRIDE_NEW_PROFILE;
}
if (AppConstants.TOR_BROWSER_VERSION != savedTBVersion) {
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
prefb.setCharPref(kTBSavedVersionPref, AppConstants.TOR_BROWSER_VERSION);
return OVERRIDE_NEW_MSTONE;
}
if (buildID != savedBuildID) {
......@@ -645,6 +668,13 @@ nsBrowserContentHandler.prototype = {
"browser.startup.homepage_override.buildID",
"unknown"
);
// We do the same for the Tor Browser version.
let old_tbversion = null;
try {
old_tbversion = prefb.getCharPref(kTBSavedVersionPref);
} catch (e) {}
override = needHomepageOverride(prefb);
if (override != OVERRIDE_NONE) {
switch (override) {
......@@ -677,9 +707,10 @@ nsBrowserContentHandler.prototype = {
"startup.homepage_override_url"
);
let update = UpdateManager.activeUpdate;
let old_version = old_tbversion ? old_tbversion: old_mstone;
if (
update &&
Services.vc.compare(update.appVersion, old_mstone) > 0
Services.vc.compare(update.appVersion, old_version) > 0
) {
overridePage = getPostUpdateOverridePage(update, overridePage);
// Send the update ping to signal that the update was successful.
......@@ -687,6 +718,8 @@ nsBrowserContentHandler.prototype = {
}
overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
overridePage = overridePage.replace("%OLD_TOR_BROWSER_VERSION%",
old_tbversion);
break;
case OVERRIDE_NEW_BUILD_ID:
if (UpdateManager.activeUpdate) {
......
......@@ -143,14 +143,15 @@
<popupnotification id="appMenu-update-restart-notification"
popupid="update-restart"
data-lazy-l10n-id="appmenu-update-restart"
data-l10n-attrs="buttonlabel, buttonaccesskey, secondarybuttonlabel, secondarybuttonaccesskey"
data-l10n-attrs="buttonaccesskey, secondarybuttonlabel, secondarybuttonaccesskey"
buttonlabel="&updateRestart.panelUI.label2;"
closebuttonhidden="true"
dropmarkerhidden="true"
checkboxhidden="true"
buttonhighlight="true"
hidden="true">
<popupnotificationcontent id="update-restart-notification-content" orient="vertical">
<description id="update-restart-description" data-lazy-l10n-id="appmenu-update-restart-message"></description>
<description id="update-restart-description">&#160;</description>
</popupnotificationcontent>
</popupnotification>
......@@ -223,8 +224,7 @@
<vbox class="panel-subview-body">
<vbox id="appMenu-addon-banners"/>
<toolbarbutton id="appMenu-update-banner" class="panel-banner-item"
data-l10n-id="appmenuitem-update-banner"
data-l10n-attrs="label-update-downloading"
label-update-downloading="Downloading update"
label-update-available="&updateAvailable.panelUI.label;"
label-update-manual="&updateManual.panelUI.label;"
label-update-unsupported="&updateUnsupported.panelUI.label;"
......
......@@ -59,6 +59,7 @@ const PanelUI = {
init() {
this._initElements();
this._initUpdaterStrings();
this.menuButton.addEventListener("mousedown", this);
this.menuButton.addEventListener("keypress", this);
......@@ -147,6 +148,27 @@ const PanelUI = {
}
},
_initUpdaterStrings() {
// If Torbutton is installed and enabled, replace the "Downloading update"
// string with one from torbutton.properties (to facilitate localization).
// This function can be removed when Tor Browser is based on Firefox 79
// or newer (where the localized string is included in the Firefox
// language packs).
try {
let brands = Services.strings.createBundle(
"chrome://branding/locale/brand.properties");
let stringArgs = [brands.GetStringFromName("brandShortName")];
let torbuttonBundle = Services.strings.createBundle(
"chrome://torbutton/locale/torbutton.properties");
let label = torbuttonBundle.formatStringFromName(
"updateDownloadingPanelUILabel", stringArgs, 1);
let elem = document.getElementById("appMenu-update-banner");
if (elem) {
elem.setAttribute("label-update-downloading", label);
}
} catch (e) {}
},
_eventListenersAdded: false,
_ensureEventListenersAdded() {
if (this._eventListenersAdded) {
......
......@@ -7,26 +7,6 @@ MOZ_APP_BASENAME=Firefox
MOZ_APP_VENDOR=Mozilla
MOZ_UPDATER=1
if test "$OS_ARCH" = "WINNT"; then
if ! test "$HAVE_64BIT_BUILD"; then
if test "$MOZ_UPDATE_CHANNEL" = "nightly" -o \
"$MOZ_UPDATE_CHANNEL" = "nightly-try" -o \
"$MOZ_UPDATE_CHANNEL" = "aurora" -o \
"$MOZ_UPDATE_CHANNEL" = "beta" -o \
"$MOZ_UPDATE_CHANNEL" = "release"; then
if ! test "$MOZ_DEBUG"; then
if ! test "$USE_STUB_INSTALLER"; then
# Expect USE_STUB_INSTALLER from taskcluster for downstream task consistency
echo "ERROR: STUB installer expected to be enabled but"
echo "ERROR: USE_STUB_INSTALLER is not specified in the environment"
exit 1
fi
MOZ_STUB_INSTALLER=1
fi
fi
fi
fi
BROWSER_CHROME_URL=chrome://browser/content/browser.xhtml
# MOZ_APP_DISPLAYNAME will be set by branding/configure.sh
......@@ -39,6 +19,21 @@ MOZ_BRANDING_DIRECTORY=browser/branding/unofficial
MOZ_OFFICIAL_BRANDING_DIRECTORY=browser/branding/official
MOZ_APP_ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
# ACCEPTED_MAR_CHANNEL_IDS should usually be the same as the value MAR_CHANNEL_ID.
# If more than one ID is needed, then you should use a comma separated list
# of values.
# The MAR_CHANNEL_ID must not contain the following 3 characters: ",\t "
if test "$MOZ_UPDATE_CHANNEL" = "alpha"; then
ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-alpha
MAR_CHANNEL_ID=torbrowser-torproject-alpha
elif test "$MOZ_UPDATE_CHANNEL" = "nightly"; then
ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-nightly
MAR_CHANNEL_ID=torbrowser-torproject-nightly
else
ACCEPTED_MAR_CHANNEL_IDS=torbrowser-torproject-release
MAR_CHANNEL_ID=torbrowser-torproject-release
fi
MOZ_PROFILE_MIGRATOR=1
# Include the DevTools client, not just the server (which is the default)
......
......@@ -36,8 +36,10 @@
; Mac bundle stuff
@APPNAME@/Contents/Info.plist
#ifdef MOZ_UPDATER
#ifndef TOR_BROWSER_UPDATE
@APPNAME@/Contents/Library/LaunchServices
#endif
#endif
@APPNAME@/Contents/PkgInfo
@RESPATH@/firefox.icns
@RESPATH@/document.icns
......
......@@ -52,5 +52,5 @@ ServerURL=https://crash-reports.mozilla.com/submit?id=@MOZ_APP_ID@&version=@MOZ_
#if MOZ_UPDATER
[AppUpdate]
URL=https://@MOZ_APPUPDATE_HOST@/update/6/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%SYSTEM_CAPABILITIES%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml
URL=https://aus1.torproject.org/torbrowser/update_3/%CHANNEL%/%BUILD_TARGET%/%VERSION%/%LOCALE%
#endif
......@@ -1147,7 +1147,6 @@ def version_path(path):
# set RELEASE_OR_BETA and NIGHTLY_BUILD variables depending on the cycle we're in
# The logic works like this:
# - if we have "a1" in GRE_MILESTONE, we're building Nightly (define NIGHTLY_BUILD)
# - otherwise, if we have "a" in GRE_MILESTONE, we're building Nightly or Aurora
# - otherwise, we're building Release/Beta (define RELEASE_OR_BETA)
@depends(check_build_environment, build_project, version_path, '--help')
@imports(_from='__builtin__', _import='open')
......@@ -1194,7 +1193,7 @@ def milestone(build_env, build_project, version_path, _):
if 'a1' in milestone:
is_nightly = True
elif 'a' not in milestone:
else:
is_release_or_beta = True
major_version = milestone.split('.')[0]
......
......@@ -5,6 +5,7 @@
# update instructions which is used to remove files and directories that are no
# longer present in a complete update. The current working directory is used for
# the location to enumerate and to create the precomplete file.
# For symlinks, remove instructions are always generated.
from __future__ import absolute_import
from __future__ import unicode_literals
......@@ -13,9 +14,17 @@ import os
import io
# TODO When TOR_BROWSER_DATA_OUTSIDE_APP_DIR is used on all platforms,
# we should remove all lines in this file that contain:
# TorBrowser/Data
def get_build_entries(root_path):
""" Iterates through the root_path, creating a list for each file and
directory. Excludes any file paths ending with channel-prefs.js.
To support Tor Browser updates, excludes:
TorBrowser/Data/Browser/profiles.ini
TorBrowser/Data/Browser/profile.default/bookmarks.html
TorBrowser/Data/Tor/torrc
"""
rel_file_path_set = set()
rel_dir_path_set = set()
......@@ -26,6 +35,9 @@ def get_build_entries(root_path):
rel_path_file = rel_path_file.replace("\\", "/")
if not (rel_path_file.endswith("channel-prefs.js") or
rel_path_file.endswith("update-settings.ini") or
rel_path_file == "TorBrowser/Data/Browser/profiles.ini" or
rel_path_file == "TorBrowser/Data/Browser/profile.default/bookmarks.html" or
rel_path_file == "TorBrowser/Data/Tor/torrc" or
rel_path_file.find("distribution/") != -1):
rel_file_path_set.add(rel_path_file)
......@@ -34,7 +46,10 @@ def get_build_entries(root_path):
rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
if rel_path_dir.find("distribution/") == -1:
rel_dir_path_set.add(rel_path_dir)
if (os.path.islink(rel_path_dir[:-1])):
rel_file_path_set.add(rel_path_dir[:-1])
else:
rel_dir_path_set.add(rel_path_dir)
rel_file_path_list = list(rel_file_path_set)
rel_file_path_list.sort(reverse=True)
......
......@@ -70,6 +70,11 @@ async function getRuntimeIcon(runtime, channel) {
}
}
// Use the release build skin for devtools within Tor Browser alpha releases.
if (channel === "alpha") {
return "chrome://devtools/skin/images/aboutdebugging-firefox-release.svg";
}
return channel === "release" || channel === "beta" || channel === "aurora"
? `chrome://devtools/skin/images/aboutdebugging-firefox-${channel}.svg`
: "chrome://devtools/skin/images/aboutdebugging-firefox-nightly.svg";
......
......@@ -103,7 +103,7 @@ var UpdateUtils = {
case "PRODUCT":
return Services.appinfo.name;
case "VERSION":
return Services.appinfo.version;
return AppConstants.TOR_BROWSER_VERSION;
case "BUILD_ID":
return Services.appinfo.appBuildID;
case "BUILD_TARGET":
......@@ -167,25 +167,17 @@ var UpdateUtils = {
* downloads and installs updates. This corresponds to whether or not the user
* has selected "Automatically install updates" in about:preferences.
*
* On Windows, this setting is shared across all profiles for the installation
* On Windows (except in Tor Browser), this setting is shared across all profiles
* for the installation
* and is read asynchronously from the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
* @return A Promise that resolves with a boolean.
*/
getAppUpdateAutoEnabled() {
if (Services.policies) {
if (!Services.policies.isAllowed("app-auto-updates-off")) {
// We aren't allowed to turn off auto-update - it is forced on.
return Promise.resolve(true);
}
if (!Services.policies.isAllowed("app-auto-updates-on")) {
// We aren't allowed to turn on auto-update - it is forced off.
return Promise.resolve(false);
}
}
if (AppConstants.platform != "win") {
// On platforms other than Windows the setting is stored in a preference.
if (AppConstants.TOR_BROWSER_UPDATE || (AppConstants.platform != "win")) {
// On platforms other than Windows and always in Tor Browser the setting
// is stored in a preference.
let prefValue = Services.prefs.getBoolPref(
PREF_APP_UPDATE_AUTO,
DEFAULT_APP_UPDATE_AUTO
......@@ -256,7 +248,8 @@ var UpdateUtils = {
* updates" and "Check for updates but let you choose to install them" options
* in about:preferences.
*
* On Windows, this setting is shared across all profiles for the installation
* On Windows (except in Tor Browser), this setting is shared across all profiles
* for the installation
* and is written asynchronously to the file. On other operating systems, this
* setting is stored in a pref and is thus a per-profile setting.
*
......@@ -276,14 +269,9 @@ var UpdateUtils = {
* this operation simply sets a pref.
*/
setAppUpdateAutoEnabled(enabledValue) {
if (this.appUpdateAutoSettingIsLocked()) {
return Promise.reject(
"setAppUpdateAutoEnabled: Unable to change value of setting because " +
"it is locked by policy"
);
}
if (AppConstants.platform != "win") {
// Only in Windows do we store the update config in the update directory
if (AppConstants.TOR_BROWSER_UPDATE || (AppConstants.platform != "win")) {
// Only in Windows (but never for Tor Browser) do we store the update config
// in the update directory
let prefValue = !!enabledValue;
Services.prefs.setBoolPref(PREF_APP_UPDATE_AUTO, prefValue);
// Rather than call maybeUpdateAutoConfigChanged, a pref observer has
......
......@@ -23,6 +23,7 @@ const { AppConstants } = ChromeUtils.import(
const MOZ_COMPATIBILITY_NIGHTLY = ![
"aurora",
"alpha",
"beta",
"release",
"esr",
......@@ -37,6 +38,7 @@ const PREF_EM_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_SYS_ADDON_UPDATE_ENABLED = "extensions.systemAddon.update.enabled";
const PREF_EM_LAST_TORBROWSER_VERSION = "extensions.lastTorBrowserVersion";
const PREF_MIN_WEBEXT_PLATFORM_VERSION =
"extensions.webExtensionsMinPlatformVersion";
......@@ -682,6 +684,28 @@ var AddonManagerInternal = {
);
}
// To ensure that extension and plugin code gets a chance to run
// after each browser update, set appChanged = true when the
// Tor Browser version has changed even if the Mozilla app
// version has not changed.
let tbChanged = undefined;
try {
tbChanged = AppConstants.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,
AppConstants.TOR_BROWSER_VERSION);
}
if (!MOZ_COMPATIBILITY_NIGHTLY) {
PREF_EM_CHECK_COMPATIBILITY =
PREF_EM_CHECK_COMPATIBILITY_BASE +
......
......@@ -43,6 +43,7 @@ var PREF_CHECK_COMPATIBILITY;
var channel = Services.prefs.getCharPref("app.update.channel", "default");
if (
channel != "aurora" &&
channel != "alpha" &&
channel != "beta" &&
channel != "release" &&
channel != "esr"
......
......@@ -379,6 +379,7 @@ function isNightlyChannel() {
return (
channel != "aurora" &&
channel != "alpha" &&
channel != "beta" &&
channel != "release" &&
channel != "esr"
......
......@@ -32,11 +32,15 @@ XPCOMUtils.defineLazyGlobalGetters(this, ["DOMParser", "XMLHttpRequest"]);
XPCOMUtils.defineLazyModuleGetters(this, {
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
CertUtils: "resource://gre/modules/CertUtils.jsm",
#ifdef XP_WIN
ctypes: "resource://gre/modules/ctypes.jsm",
#endif
DeferredTask: "resource://gre/modules/DeferredTask.jsm",
OS: "resource://gre/modules/osfile.jsm",
UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
#if !defined(TOR_BROWSER_UPDATE)
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
#endif
});
const UPDATESERVICE_CID = Components.ID(
......@@ -296,6 +300,7 @@ function testWriteAccess(updateTestFile, createDirectory) {
updateTestFile.remove(false);
}
#ifdef XP_WIN
/**
* Windows only function that closes a Win32 handle.
*
......@@ -388,6 +393,7 @@ function getPerInstallationMutexName(aGlobal = true) {
(aGlobal ? "Global\\" : "") + "MozillaUpdateMutex-" + hasher.finish(true)
);
}
#endif
/**
* Whether or not the current instance has the update mutex. The update mutex
......@@ -398,6 +404,7 @@ function getPerInstallationMutexName(aGlobal = true) {
* @return true if this instance holds the update mutex
*/
function hasUpdateMutex() {
#ifdef XP_WIN
if (AppConstants.platform != "win") {
return true;
}
......@@ -405,6 +412,9 @@ function hasUpdateMutex() {
gUpdateMutexHandle = createMutex(getPerInstallationMutexName(true), false);
}
return !!gUpdateMutexHandle;
#else
return true;
#endif
}
/**
......@@ -435,6 +445,11 @@ function areDirectoryEntriesWriteable(aDir) {
* @return true if elevation is required, false otherwise
*/
function getElevationRequired() {
#if defined(TOR_BROWSER_UPDATE)
// To avoid potential security holes associated with running the updater
// process with elevated privileges, Tor Browser does not support elevation.
return false;
#else
if (AppConstants.platform != "macosx") {
return false;
}
......@@ -469,6 +484,7 @@ function getElevationRequired() {
"not required"
);
return false;
#endif
}
/**
......@@ -501,6 +517,7 @@ function getCanApplyUpdates() {
return false;
}