Bug 1539784 - ensure the master-password is unlocked before disconnecting from sync. r=eoger a=pascalc
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 10 Apr 2019 15:41:28 +0000
changeset 526158 37c5083230c5128f5c66ed88549e4471572d0e18
parent 526157 68224b37ba35a78be80382f9c2c52fba23a2c5df
child 526159 8f56f6681da40857faa243da02f4d1fcb1dfaf2d
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseoger, pascalc
bugs1539784
milestone67.0
Bug 1539784 - ensure the master-password is unlocked before disconnecting from sync. r=eoger a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D26870
services/sync/modules/SyncDisconnect.jsm
--- a/services/sync/modules/SyncDisconnect.jsm
+++ b/services/sync/modules/SyncDisconnect.jsm
@@ -9,16 +9,17 @@ const {XPCOMUtils} = ChromeUtils.import(
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   Services: "resource://gre/modules/Services.jsm",
   Log: "resource://gre/modules/Log.jsm",
   Sanitizer: "resource:///modules/Sanitizer.jsm",
   AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
   fxAccounts: "resource://gre/modules/FxAccounts.jsm",
   setTimeout: "resource://gre/modules/Timer.jsm",
+  Utils: "resource://services-sync/util.js",
 });
 
 XPCOMUtils.defineLazyGetter(this, "FxAccountsCommon", function() {
   return ChromeUtils.import("resource://gre/modules/FxAccountsCommon.js", {});
 });
 
 this.EXPORTED_SYMBOLS = ["SyncDisconnect"];
 
@@ -152,16 +153,25 @@ this.SyncDisconnectInternal = {
                          {sanitizeSyncData = false, sanitizeBrowserData = false} = {}) {
     // This is a bit convoluted - we want to wait for a sync to finish before
     // sanitizing, but want to abort that wait if the browser shuts down while
     // we are waiting (in which case we'll charge ahead anyway).
     // So we do this by using an AbortController and passing that to the
     // function that waits for the sync lock - it will immediately resolve
     // if the abort controller is aborted.
     let log = Log.repository.getLogger("Sync.Service");
+
+    // If the master-password is locked then we will fail to fully sanitize,
+    // so prompt for that now. If canceled, we just abort now.
+    log.info("checking master-password state");
+    if (!Utils.ensureMPUnlocked()) {
+      log.warn("The master-password needs to be unlocked to fully disconnect from sync");
+      return;
+    }
+
     log.info("waiting for any existing syncs to complete");
     let locked = await this.promiseNotSyncing(abortController);
 
     if (sanitizeSyncData) {
       await this.doSanitizeSyncData();
     }
 
     // We disconnect before sanitizing the browser data - in a worst-case