Commit 12b3435d authored by Kathleen Brade's avatar Kathleen Brade Committed by Alex Catarineu
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 Br...
parent d840ae17
......@@ -99,10 +99,12 @@ tools repackage:: $(DIST)/bin/$(MOZ_APP_NAME) $(objdir)/macbuild/Contents/MacOS-
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>
......
......@@ -6,26 +6,6 @@
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
......@@ -38,6 +18,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
......@@ -1162,7 +1162,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')
......@@ -1209,7 +1208,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)
......
......@@ -67,6 +67,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";
......@@ -691,6 +693,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"
......
......@@ -390,6 +390,7 @@ function isNightlyChannel() {
return (
channel != "aurora" &&
channel != "alpha" &&
channel != "beta" &&
channel != "release" &&
channel != "esr"
......
......@@ -33,12 +33,16 @@ XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
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",
setTimeout: "resource://gre/modules/Timer.jsm",
UpdateUtils: "resource://gre/modules/UpdateUtils.jsm",
#if !defined(TOR_BROWSER_UPDATE)
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
#endif
});
const UPDATESERVICE_CID = Components.ID(
......@@ -336,6 +340,7 @@ function testWriteAccess(updateTestFile, createDirectory) {
updateTestFile.remove(false);
}
#ifdef XP_WIN
/**
* Windows only function that closes a Win32 handle.
*
......@@ -428,6 +433,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
......@@ -438,6 +444,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;
}
......@@ -445,6 +452,9 @@ function hasUpdateMutex() {
gUpdateMutexHandle = createMutex(getPerInstallationMutexName(true), false);
}
return !!gUpdateMutexHandle;
#else
return true;
#endif
}
/**
......@@ -475,6 +485,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;
}
......@@ -509,6 +524,7 @@ function getElevationRequired() {
"not required"
);
return false;
#endif
}
/**
......@@ -558,6 +574,7 @@ function getCanApplyUpdates() {
return false;
}
#if !defined(TOR_BROWSER_UPDATE)
if (AppConstants.platform == "macosx") {
LOG(
"getCanApplyUpdates - bypass the write since elevation can be used " +
......@@ -573,6 +590,7 @@ function getCanApplyUpdates() {
);
return true;
}
#endif
try {
if (AppConstants.platform == "win") {
......@@ -1260,6 +1278,9 @@ function handleUpdateFailure(update, errorCode) {
cancelations++;
Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations);
if (AppConstants.platform == "macosx") {
#if defined(TOR_BROWSER_UPDATE)
cleanupActiveUpdate();
#else
let osxCancelations = Services.prefs.getIntPref(
PREF_APP_UPDATE_CANCELATIONS_OSX,
0
......@@ -1283,6 +1304,7 @@ function handleUpdateFailure(update, errorCode) {
(update.state = STATE_PENDING_ELEVATE)
);
}
#endif
update.statusText = gUpdateBundle.GetStringFromName("elevationFailure");
} else {
writeStatusFile(getUpdatesDir(), (update.state = STATE_PENDING));
......@@ -1809,7 +1831,26 @@ function Update(update) {
this._patches.push(patch);
}
if (!this._patches.length && !update.hasAttribute("unsupported")) {
if (update.hasAttribute("unsupported")) {
this.unsupported = ("true" == update.getAttribute("unsupported"));
} else if (update.hasAttribute("minSupportedOSVersion")) {
let minOSVersion = update.getAttribute("minSupportedOSVersion");
try {
let osVersion = Services.sysinfo.getProperty("version");
this.unsupported = (Services.vc.compare(osVersion, minOSVersion) < 0);
} catch (e) {}
}
if (!this.unsupported && update.hasAttribute("minSupportedInstructionSet")) {
let minInstructionSet = update.getAttribute("minSupportedInstructionSet");