[tbb-commits] [tor-launcher/master] Bug 31491: clean up the old meek http helper browser profiles

gk at torproject.org gk at torproject.org
Sun Sep 22 05:50:25 UTC 2019


commit d78a233bc597c8df63e794f880a1a7f54fb9cebd
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Thu Sep 19 16:01:42 2019 -0400

    Bug 31491: clean up the old meek http helper browser profiles
    
    On macOS, remove the old meek and moat http helper browser profiles
    that may be present under TorBrowser-Data/Tor/PluggableTransports/.
    Removal is only attempted once; this is controlled by the Boolean pref
    extensions.torlauncher.should_remove_meek_helper_profiles.
---
 src/components/tl-process.js                  |  2 ++
 src/defaults/preferences/torlauncher-prefs.js |  7 ++++++
 src/modules/tl-util.jsm                       | 36 +++++++++++++++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index 3aa45e4..49abc0a 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -112,6 +112,8 @@ TorProcessService.prototype =
                                      Cr.NS_ERROR_NOT_INITIALIZED);
       }
 
+      TorLauncherUtil.removeMeekAndMoatHelperProfiles();
+
       if (TorLauncherUtil.shouldOnlyConfigureTor)
       {
         this._controlTor(true, false);
diff --git a/src/defaults/preferences/torlauncher-prefs.js b/src/defaults/preferences/torlauncher-prefs.js
index cc6b1a7..55fe38c 100644
--- a/src/defaults/preferences/torlauncher-prefs.js
+++ b/src/defaults/preferences/torlauncher-prefs.js
@@ -5,6 +5,13 @@ pref("extensions.torlauncher.prompt_for_locale", true);
 pref("extensions.torlauncher.start_tor", true);
 pref("extensions.torlauncher.prompt_at_startup", true);
 
+// This pref controls whether Tor Launcher will try to remove the old
+// meek and moat http helper browser profiles. This only has an effect
+// on macOS; for Windows and Linux profile removal is handled by the
+// updater (since on those platforms the profiles are embedded within
+// the browser install directory).
+pref("extensions.torlauncher.should_remove_meek_helper_profiles", true);
+
 pref("extensions.torlauncher.loglevel", 4);  // 1=verbose, 2=debug, 3=info, 4=note, 5=warn
 pref("extensions.torlauncher.logmethod", 1);  // 0=stdout, 1=errorconsole, 2=debuglog
 pref("extensions.torlauncher.max_tor_log_entries", 1000);
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index 14ac76f..c54acb9 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -758,6 +758,42 @@ let TorLauncherUtil =  // Public
       }
     } catch(e) {}
   },
+
+  removeMeekAndMoatHelperProfiles: function()
+  {
+    function removeDirectory(aParentDir, aName)
+    {
+      try
+      {
+        let dir = aParentDir.clone();
+        dir.appendRelativePath(aName);
+        if (dir.exists())
+          dir.remove(true);
+      }
+      catch (e)
+      {
+        TorLauncherLogger.log(5, "Failed to remove " + aName + ": " + e);
+      }
+    }
+
+    const kPrefRemoveHelperProfiles =
+                "extensions.torlauncher.should_remove_meek_helper_profiles";
+    if (this.getBoolPref(kPrefRemoveHelperProfiles, false))
+    {
+      // Only attempt removal once.
+      this.setBoolPref(kPrefRemoveHelperProfiles, false);
+
+      if (this.isMac)
+      {
+        let ptProfilesDir = this.getTorFile("pt-profiles-dir", true);
+        if (ptProfilesDir)
+        {
+          removeDirectory(ptProfilesDir, "profile.meek-http-helper");
+          removeDirectory(ptProfilesDir, "profile.moat-http-helper");
+        }
+      }
+    }
+  },
 };
 
 



More information about the tbb-commits mailing list