mozilla-bmo1464766.patch
branchfirefox60
changeset 1064 af29b3ac33ae
child 1091 cbed5671ff47
equal deleted inserted replaced
1062:48d794331fce 1064:af29b3ac33ae
       
     1 
       
     2 # HG changeset patch
       
     3 # User Mike Hommey <mh+mozilla@glandium.org>
       
     4 # Date 1527491713 -32400
       
     5 # Node ID c28becad0c10b906454d7e424f9a9402799ea8dd
       
     6 # Parent  a830c8302c71a45e019fe14e16945b32346b2253
       
     7 Bug 1464766 - Allow to relax the addon signature requirements. r?rhelmer
       
     8 
       
     9 diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
       
    10 --- a/modules/libpref/init/all.js
       
    11 +++ b/modules/libpref/init/all.js
       
    12 @@ -1256,16 +1256,19 @@ pref("print.print_via_parent", true);
       
    13  pref("print.print_via_parent", false);
       
    14  #endif
       
    15  
       
    16  // Pref used by the spellchecker extension to control the
       
    17  // maximum number of misspelled words that will be underlined
       
    18  // in a document.
       
    19  pref("extensions.spellcheck.inline.max-misspellings", 500);
       
    20  
       
    21 +// Add-on manager scoped allowing unsigned addons. None by default.
       
    22 +pref("extensions.unsignedScopes", 12, locked);
       
    23 +
       
    24  // Prefs used by libeditor. Prefs specific to seamonkey composer
       
    25  // belong in comm-central/editor/ui/composer.js
       
    26  
       
    27  pref("editor.use_custom_colors", false);
       
    28  pref("editor.singleLine.pasteNewlines",      2);
       
    29  pref("editor.use_css",                       false);
       
    30  pref("editor.css.default_length_unit",       "px");
       
    31  pref("editor.resizing.preserve_ratio",       true);
       
    32 diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js
       
    33 --- a/toolkit/mozapps/extensions/content/extensions.js
       
    34 +++ b/toolkit/mozapps/extensions/content/extensions.js
       
    35 @@ -47,16 +47,17 @@ XPCOMUtils.defineLazyPreferenceGetter(th
       
    36  const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
       
    37  const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
       
    38  const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
       
    39  const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
       
    40  const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden";
       
    41  const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
       
    42  const PREF_LEGACY_EXCEPTIONS = "extensions.legacy.exceptions";
       
    43  const PREF_LEGACY_ENABLED = "extensions.legacy.enabled";
       
    44 +const PREF_UNSIGNED_SCOPES = "extensions.unsignedScopes";
       
    45  
       
    46  const LOADING_MSG_DELAY = 100;
       
    47  
       
    48  const UPDATES_RECENT_TIMESPAN = 2 * 24 * 3600000; // 2 days (in milliseconds)
       
    49  const UPDATES_RELEASENOTES_TRANSFORMFILE = "chrome://mozapps/content/extensions/updateinfo.xsl";
       
    50  
       
    51  const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
       
    52  
       
    53 @@ -229,19 +230,21 @@ function loadView(aViewId) {
       
    54  
       
    55  function isCorrectlySigned(aAddon) {
       
    56    // Add-ons without an "isCorrectlySigned" property are correctly signed as
       
    57    // they aren't the correct type for signing.
       
    58    return aAddon.isCorrectlySigned !== false;
       
    59  }
       
    60  
       
    61  function isDisabledUnsigned(addon) {
       
    62 -  let signingRequired = (addon.type == "locale") ?
       
    63 -                        AddonSettings.LANGPACKS_REQUIRE_SIGNING :
       
    64 -                        AddonSettings.REQUIRE_SIGNING;
       
    65 +  let unsignedScopes = Services.prefs.getIntPref(PREF_UNSIGNED_SCOPES, 0);
       
    66 +  let signingRequired = !(addon.scope & unsignedScopes) &&
       
    67 +                        ((addon.type == "locale") ?
       
    68 +                         AddonSettings.LANGPACKS_REQUIRE_SIGNING :
       
    69 +                         AddonSettings.REQUIRE_SIGNING);
       
    70    return signingRequired && !isCorrectlySigned(addon);
       
    71  }
       
    72  
       
    73  function isLegacyExtension(addon) {
       
    74    let legacy = false;
       
    75    if (addon.type == "extension" && !addon.isWebExtension) {
       
    76      legacy = true;
       
    77    }
       
    78 diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
       
    79 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
       
    80 +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
       
    81 @@ -66,16 +66,17 @@ const PREF_XPI_STATE                  = 
       
    82  const PREF_BLOCKLIST_ITEM_URL         = "extensions.blocklist.itemURL";
       
    83  const PREF_BOOTSTRAP_ADDONS           = "extensions.bootstrappedAddons";
       
    84  const PREF_PENDING_OPERATIONS         = "extensions.pendingOperations";
       
    85  const PREF_SKIN_SWITCHPENDING         = "extensions.dss.switchPending";
       
    86  const PREF_SKIN_TO_SELECT             = "extensions.lastSelectedSkin";
       
    87  const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
       
    88  const PREF_EM_EXTENSION_FORMAT        = "extensions.";
       
    89  const PREF_EM_ENABLED_SCOPES          = "extensions.enabledScopes";
       
    90 +const PREF_EM_UNSIGNED_SCOPES         = "extensions.unsignedScopes";
       
    91  const PREF_EM_STARTUP_SCAN_SCOPES     = "extensions.startupScanScopes";
       
    92  const PREF_EM_SHOW_MISMATCH_UI        = "extensions.showMismatchUI";
       
    93  const PREF_XPI_ENABLED                = "xpinstall.enabled";
       
    94  const PREF_XPI_WHITELIST_REQUIRED     = "xpinstall.whitelist.required";
       
    95  const PREF_XPI_DIRECT_WHITELISTED     = "xpinstall.whitelist.directRequest";
       
    96  const PREF_XPI_FILE_WHITELISTED       = "xpinstall.whitelist.fileRequest";
       
    97  // xpinstall.signatures.required only supported in dev builds
       
    98  const PREF_XPI_SIGNATURES_REQUIRED    = "xpinstall.signatures.required";
       
    99 @@ -801,17 +802,19 @@ function isDisabledLegacy(addon) {
       
   100   *         The add-on to check
       
   101   * @return true if the add-on should not be appDisabled
       
   102   */
       
   103  function isUsableAddon(aAddon) {
       
   104    // Hack to ensure the default theme is always usable
       
   105    if (aAddon.type == "theme" && aAddon.internalName == XPIProvider.defaultSkin)
       
   106      return true;
       
   107  
       
   108 -  if (mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
       
   109 +  let unsignedScopes = Services.prefs.getIntPref(PREF_EM_UNSIGNED_SCOPES, 0);
       
   110 +  if (!(aAddon._installLocation.scope & unsignedScopes) &&
       
   111 +      mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
       
   112      logger.warn(`Add-on ${aAddon.id} is not correctly signed.`);
       
   113      if (Services.prefs.getBoolPref(PREF_XPI_SIGNATURES_DEV_ROOT, false)) {
       
   114        logger.warn(`Preference ${PREF_XPI_SIGNATURES_DEV_ROOT} is set.`);
       
   115      }
       
   116      return false;
       
   117    }
       
   118  
       
   119    if (aAddon.blocklistState == nsIBlocklistService.STATE_BLOCKED) {
       
   120 diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
       
   121 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
       
   122 +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
       
   123 @@ -39,16 +39,17 @@ var logger = Log.repository.getLogger(LO
       
   124  const KEY_PROFILEDIR                  = "ProfD";
       
   125  const FILE_JSON_DB                    = "extensions.json";
       
   126  
       
   127  // The last version of DB_SCHEMA implemented in SQLITE
       
   128  const LAST_SQLITE_DB_SCHEMA           = 14;
       
   129  const PREF_DB_SCHEMA                  = "extensions.databaseSchema";
       
   130  const PREF_PENDING_OPERATIONS         = "extensions.pendingOperations";
       
   131  const PREF_EM_AUTO_DISABLED_SCOPES    = "extensions.autoDisableScopes";
       
   132 +const PREF_EM_UNSIGNED_SCOPES         = "extensions.unsignedScopes";
       
   133  
       
   134  const KEY_APP_SYSTEM_ADDONS           = "app-system-addons";
       
   135  const KEY_APP_SYSTEM_DEFAULTS         = "app-system-defaults";
       
   136  const KEY_APP_GLOBAL                  = "app-global";
       
   137  const KEY_APP_TEMPORARY               = "app-temporary";
       
   138  
       
   139  // Properties to save in JSON file
       
   140  const PROP_JSON_FIELDS = ["id", "syncGUID", "location", "version", "type",