[tor-commits] [torbutton/master] Bug 40006: Fix new identity for 81

gk at torproject.org gk at torproject.org
Thu Aug 27 09:48:04 UTC 2020


commit 72cbb6d501aa798a676da9331e686581ee4038cf
Author: Alex Catarineu <acat at torproject.org>
Date:   Wed Aug 26 12:29:31 2020 +0200

    Bug 40006: Fix new identity for 81
    
    New identity tries to disable some buttons to prevent them from
    being clicked while doing a new identity. These are now initialized
    lazily, which makes the current code fail. Instead of doing that,
    we now avoid disabling the buttons and ignore new identity requests
    while one is in progress.
---
 chrome/content/torbutton.js | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/chrome/content/torbutton.js b/chrome/content/torbutton.js
index 0d2e7e2d..a9d4ccd1 100644
--- a/chrome/content/torbutton.js
+++ b/chrome/content/torbutton.js
@@ -760,15 +760,18 @@ torbutton_new_circuit = function() {
   gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
 }
 
+let newIdentityInProgress = false;
+
 // Bug 1506 P4: Needed for New Identity.
 torbutton_new_identity = async function() {
   try {
-    // Make sure that we can only click once on New Identiy to avoid race
+    // Ignore if there's a New Identity in progress to avoid race
     // conditions leading to failures (see bug 11783 for an example).
-    // TODO: Remove the Torbutton menu entry again once we have done our
-    // security control redesign.
-    document.getElementById("menu_newIdentity").disabled = true;
-    document.getElementById("appMenuNewIdentity").disabled = true;
+    if (newIdentityInProgress) {
+      return;
+    }
+
+    newIdentityInProgress = true;
 
     let shouldConfirm =  m_tb_prefs.getBoolPref("extensions.torbutton.confirm_newnym");
 
@@ -789,14 +792,9 @@ torbutton_new_identity = async function() {
 
       if (confirmed) {
         await torbutton_do_new_identity();
-      } else {
-        // TODO: Remove the Torbutton menu entry again once we have done our
-        // security control redesign.
-        document.getElementById("menu_newIdentity").disabled = false;
-        document.getElementById("appMenuNewIdentity").disabled = false;
       }
     } else {
-        await torbutton_do_new_identity();
+      await torbutton_do_new_identity();
     }
   } catch(e) {
     // If something went wrong make sure we have the New Identity button
@@ -805,8 +803,8 @@ torbutton_new_identity = async function() {
     // security control redesign.
     torbutton_log(5, "Unexpected error on new identity: " + e);
     window.alert("Torbutton: Unexpected error on new identity: " + e);
-    document.getElementById("menu_newIdentity").disabled = false;
-    document.getElementById("appMenuNewIdentity").disabled = false;
+  } finally {
+    newIdentityInProgress = false;
   }
 }
 



More information about the tor-commits mailing list