[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] If env var TOR_SKIP_LAUNCH=1, do not start the tor process.



commit 9e444ef8062dfcdef233fc1a5e19a01afbc941c9
Author: Kathy Brade <brade@xxxxxxxxxxxxxx>
Date:   Wed Apr 10 12:01:01 2013 -0400

    If env var TOR_SKIP_LAUNCH=1, do not start the tor process.
---
 src/components/tl-process.js  |    3 +--
 src/components/tl-protocol.js |    4 +---
 src/modules/tl-util.jsm       |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index 655745e..6bff855 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -30,7 +30,6 @@ TorProcessService.prototype =
   kServiceName : "Tor Launcher Process Service",
   kClassID: Components.ID("{FE7B4CAF-BCF4-4848-8BFF-EFA66C9AFDA1}"),
 
-  kPrefStartTor: "extensions.torlauncher.start_tor",
   kPrefPromptAtStartup: "extensions.torlauncher.prompt_at_startup",
   kInitialMonitorDelayMS: 1000, // TODO: how can we avoid this delay?
   kMonitorDelayMS: 200,
@@ -78,7 +77,7 @@ TorProcessService.prototype =
       this.mObsSvc.addObserver(this, kOpenNetworkSettingsTopic, false);
       this.mObsSvc.addObserver(this, kUserQuitTopic, false);
 
-      if (TorLauncherUtil.getBoolPref(this.kPrefStartTor))
+      if (TorLauncherUtil.shouldStartAndOwnTor)
         this._startTor();
     }
     else if ("quit-application-granted" == aTopic)
diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index f760e63..15000a5 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -71,8 +71,6 @@ TorProtocolService.prototype =
   kServiceName : "Tor Launcher Protocol Service",
   kClassID: Components.ID("{4F476361-23FB-43EF-A427-B36A14D3208E}"),
 
-  kPrefStartTor: "extensions.torlauncher.start_tor",
-
   // nsISupports implementation.
   QueryInterface: function(aIID)
   {
@@ -438,7 +436,7 @@ TorProtocolService.prototype =
         return null;
       }
 
-      if (TorLauncherUtil.getBoolPref(this.kPrefStartTor))
+      if (TorLauncherUtil.shouldStartAndOwnTor)
       {
         // Try to become the primary controller (TAKEOWNERSHIP).
         reply = this._sendCommand(conn, "TAKEOWNERSHIP", null);
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index 8809ee4..0de2f05 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -128,6 +128,22 @@ let TorLauncherUtil =  // Public
 
     return rv;
   },
+
+  get shouldStartAndOwnTor()
+  {
+    const kPrefStartTor = "extensions.torlauncher.start_tor";
+    try
+    {
+      const kEnvSkipLaunch = "TOR_SKIP_LAUNCH";
+
+      var env = Cc["@mozilla.org/process/environment;1"]
+                  .getService(Ci.nsIEnvironment);
+      if (env.exists(kEnvSkipLaunch))
+        return ("1" != env.get(kEnvSkipLaunch));
+    } catch(e) {}
+
+    return this.getBoolPref(kPrefStartTor, true);
+  },
 };
 
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits