File mozilla-bmo1464766.patch of Package MozillaFirefox.11699

# HG changeset patch
# User Mike Hommey <mh+mozilla@glandium.org>
# Date 1527491713 -32400
#      Mon May 28 16:15:13 2018 +0900
# Node ID 5b21ede56c39447f368f8544ad060be6276cfafb
# Parent  9f2ccb12120128dc2bba780734b9bfacee9263bc
Bug 1464766 - Allow to relax the addon signature requirements. r?rhelmer

diff -r 9f2ccb121201 -r 5b21ede56c39 modules/libpref/init/all.js
--- a/modules/libpref/init/all.js	Wed Jun 19 08:35:32 2019 +0200
+++ b/modules/libpref/init/all.js	Mon May 28 16:15:13 2018 +0900
@@ -1259,6 +1259,9 @@
 // in a document.
 pref("extensions.spellcheck.inline.max-misspellings", 500);
 
+// Add-on manager scoped allowing unsigned addons. None by default.
+pref("extensions.unsignedScopes", 12, locked);
+
 // Prefs used by libeditor. Prefs specific to seamonkey composer
 // belong in comm-central/editor/ui/composer.js
 
diff -r 9f2ccb121201 -r 5b21ede56c39 toolkit/mozapps/extensions/content/extensions.js
--- a/toolkit/mozapps/extensions/content/extensions.js	Wed Jun 19 08:35:32 2019 +0200
+++ b/toolkit/mozapps/extensions/content/extensions.js	Mon May 28 16:15:13 2018 +0900
@@ -52,6 +52,7 @@
 const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
 const PREF_LEGACY_EXCEPTIONS = "extensions.legacy.exceptions";
 const PREF_LEGACY_ENABLED = "extensions.legacy.enabled";
+const PREF_UNSIGNED_SCOPES = "extensions.unsignedScopes";
 
 const LOADING_MSG_DELAY = 100;
 
@@ -234,9 +235,11 @@
 }
 
 function isDisabledUnsigned(addon) {
-  let signingRequired = (addon.type == "locale") ?
-                        AddonSettings.LANGPACKS_REQUIRE_SIGNING :
-                        AddonSettings.REQUIRE_SIGNING;
+  let unsignedScopes = Services.prefs.getIntPref(PREF_UNSIGNED_SCOPES, 0);
+  let signingRequired = !(addon.scope & unsignedScopes) &&
+                        ((addon.type == "locale") ?
+                         AddonSettings.LANGPACKS_REQUIRE_SIGNING :
+                         AddonSettings.REQUIRE_SIGNING);
   return signingRequired && !isCorrectlySigned(addon);
 }
 
diff -r 9f2ccb121201 -r 5b21ede56c39 toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm	Wed Jun 19 08:35:32 2019 +0200
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm	Mon May 28 16:15:13 2018 +0900
@@ -72,6 +72,7 @@
 const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
 const PREF_EM_EXTENSION_FORMAT        = "extensions.";
 const PREF_EM_ENABLED_SCOPES          = "extensions.enabledScopes";
+const PREF_EM_UNSIGNED_SCOPES         = "extensions.unsignedScopes";
 const PREF_EM_STARTUP_SCAN_SCOPES     = "extensions.startupScanScopes";
 const PREF_EM_SHOW_MISMATCH_UI        = "extensions.showMismatchUI";
 const PREF_XPI_ENABLED                = "xpinstall.enabled";
@@ -808,7 +809,9 @@
   if (aAddon.type == "theme" && aAddon.internalName == XPIProvider.defaultSkin)
     return true;
 
-  if (mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
+  let unsignedScopes = Services.prefs.getIntPref(PREF_EM_UNSIGNED_SCOPES, 0);
+  if (!(aAddon._installLocation.scope & unsignedScopes) &&
+      mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
     logger.warn(`Add-on ${aAddon.id} is not correctly signed.`);
     if (Services.prefs.getBoolPref(PREF_XPI_SIGNATURES_DEV_ROOT, false)) {
       logger.warn(`Preference ${PREF_XPI_SIGNATURES_DEV_ROOT} is set.`);
diff -r 9f2ccb121201 -r 5b21ede56c39 toolkit/mozapps/extensions/internal/XPIProviderUtils.js
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js	Wed Jun 19 08:35:32 2019 +0200
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js	Mon May 28 16:15:13 2018 +0900
@@ -44,6 +44,7 @@
 const PREF_DB_SCHEMA                  = "extensions.databaseSchema";
 const PREF_PENDING_OPERATIONS         = "extensions.pendingOperations";
 const PREF_EM_AUTO_DISABLED_SCOPES    = "extensions.autoDisableScopes";
+const PREF_EM_UNSIGNED_SCOPES         = "extensions.unsignedScopes";
 
 const KEY_APP_SYSTEM_ADDONS           = "app-system-addons";
 const KEY_APP_SYSTEM_DEFAULTS         = "app-system-defaults";