Re: [Tails-dev] Tor Launcher as a standalone XUL app in Tail…

Delete this message

Reply to this message
Autor: anonym
Data:  
Dla: The Tails public development discussion list
CC: Mike Perry, Mark Smith, Kathleen Brade
Temat: Re: [Tails-dev] Tor Launcher as a standalone XUL app in Tails
20/02/14 16:35, Mark Smith wrote:
> On 2/19/14, 2:14 PM, anonym wrote:
>> It sounds to me like the setting you are talking about does *not* have
>> any direct effect on Firefox, only on Tor Launcher. To clarify, you are
>> *not* setting e.g. `network.proxy.socks` (which Firefox itself uses),
>> instead you are setting e.g. `extensions.torlauncher.xxx` (which Firefox
>> itself doesn't use).
>>
>> Is this correct? (If so, we're happy -- see the end of this email.)
>
> Yes, I think that is correct.


Excellent!

> It is a little difficult for Kathy and me
> to separate the two things because until now we have never thought about
> Tor Launcher running in a profile separate from the one where browsing
> will be done.


Right but given the answer you gave me in the end of your email it
should be pretty straight-forward. The standalone profile will only
include whatever default settings are present in the Tor Launcher
package itself, and the ones Tor Launcher sets during its operation
(i.e. it will *not* include the TBB's settings *nor* stuff Firefox sets
during its operation). However, since those are the settings you care
about (currently, at least) you can reason about the standalone version
in exactly the same way as when it's run as a Firefox extension. It's
only when you use settings that are not exclusive to Tor Launcher that
things may get problematic.

>>> This is also why we need to start tor
>>> with DisableNetwork=1 when the "use default bridges" option is enabled:
>>>   so we can update the bridge configuration before tor starts its
>>> bootstrap process.  See:
>>>    https://trac.torproject.org/projects/tor/ticket/10418

[...]
>> Will anything change with Tor Launcher's current design of immediately
>> starting Tor and configure it to use the previous settings on all runs
>> after the very first?

[...]
> I tried to explain this in my last message but possibly I wasn't clear.
> We do not plan to show the network configuration wizard each time. The
> issue is that Tor Launcher needs to reconfigure the default bridges each
> time tor starts up. This is necessary because the default bridge
> addresses may change when TBB is upgraded (the addresses are stored as a
> series of hidden Tor Launcher preferences).


Ah, now I get it. Thanks for you patience! :)

>>> I am not sure if the concept of default bridges is something you will
>>> want for Tails in the future or not.
>>
>> It doubt it. In Tails we care about the bridges being non-public to
>> support the "hide that you are using Tor" use case as best we can. If we
>> expose our users to a convenient option to use a public list of default
>> bridges, then we put the users of that use case at risk. Therefore it'd
>> be great if whatever GUI control you'll use for this option will be
>> hidden (or at least disabled/"greyed out") if the pre-supplied list of
>> default bridges is empty/non-existent.
>
> That is already how things work. The option to use default bridges is
> only displayed if the necessary preferences are present.


Great!

>>> Another small consideration is that we (TBB developers) will probably
>>> not test Tor Launcher as a standalone XUL application because we will
>>> not be using it that way... so it is possible we will accidentally break
>>> something that is needed in that mode. Of course we will try not to
>>> do so.
>>
>> As long as Tor Launcher more or less sticks with its current design, and
>> continues to keep away from stuff directly affecting Firefox (leaving
>> that to Tor Button) and only do stuff related to
>> starting/configuring/monitoring Tor processes, I expect very little
>> problems due to your upstream changes.
>>
>> Does this look like your plan for the foreseeable future?
>
> Yes, although I leave it to Mike (in his role as TBB chief architect) to
> comment as well. Requirements may dictate a future change in direction,
> but for now the plan is for Torbutton and Tor Launcher to work together
> but maintain their distinct roles.


This is reassuring enough and welcome news! Now I truly feel confident
that the standalone XUL approach is a perfect fit for Tails for now.

Any ETA on when my patches can be reviewed? We plan to incorporate Tor
Launcher in the next Tails release (0.23) which has its feature freeze
on the 5th of March. If this could be upstreamed at the very latest the
day before that (so there's time for us to package and test it), we'd be
very happy. Of course, for that to happen the review would probably have
to happen quite soon as I'm sure there'll be some back-and-forth with me
revising the patches.

In the worst case, if it's not upstreamed in time for our freeze, we can
of course ship a patched Tor Launcher for this release and have them
upstreamed for the next release or so, so it's not an imminent, hard
requirement.

Also, see attached files for a new patch set. From now on I won't rebase
the patches any more in order to ease your review process. For the
record, I've tested the patched Tor Launcher successfully both as a
Firefox extension, and a standalone XUL application.

Cheers!

>From 90942957d98421969a8ed9538ea29eeaaec134f3 Mon Sep 17 00:00:00 2001
From: Tails developers <amnesia@???>
Date: Tue, 11 Feb 2014 00:02:22 +0100
Subject: [PATCH 1/4] Support packaging as a standalone XUL application.

---
 Makefile           |   25 +++++++++++++++++++++----
 application.ini.in |   13 +++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)
 create mode 100644 application.ini.in


diff --git a/Makefile b/Makefile
index 9c3e853..b45afa8 100644
--- a/Makefile
+++ b/Makefile
@@ -2,14 +2,19 @@
### See src/LICENSE for licensing information.

 EXT_NAME=tor-launcher
-XPI_NAME:=$(shell echo "$(EXT_NAME)-`grep em:version src/install.rdf | sed -e 's/[<>]/    /g' | cut -f3`.xpi")
+VERSION:=`grep em:version src/install.rdf | sed -e 's/[<>]/    /g' | cut -f3`
+XPI_NAME:=$(shell echo "$(EXT_NAME)-$(VERSION).xpi")
+STANDALONE_NAME=$(EXT_NAME)-standalone
+STANDALONE_TARBALL=$(shell echo "$(STANDALONE_NAME)-$(VERSION).tar.gz")


-AVAIL_TARGETS=help package clean
+AVAIL_TARGETS=help package standalone clean

 ifeq ($(VERBOSE),1)
     ZIP=zip
+    TAR=tar -v
 else
     ZIP=zip -q
+    TAR=tar
 endif


 help:
@@ -18,13 +23,25 @@ help:
         echo "  make $$t";                                                    \
     done


-package:    clean
+pkg-prepare:    clean
     @mkdir -p pkg
+
+package:    pkg-prepare
     @(cd src; $(ZIP) -X9r "../pkg/$(XPI_NAME)" ./ -x "*.diff")
     @echo "Created package pkg/$(XPI_NAME)"


+standalone:    pkg-prepare
+    @cp "application.ini.in" "src/application.ini"
+    @sed -i "s/__VERSION__/$(VERSION)/" "src/application.ini"
+    @sed -i "s/__DATE__/`date '+%Y%m%d'`/" "src/application.ini"
+    @$(TAR) --exclude "*.diff" --transform s/src/$(STANDALONE_NAME)/ \
+        -czf "pkg/$(STANDALONE_TARBALL)" src
+    @echo "Created standalone package pkg/$(STANDALONE_TARBALL)"
+
 clean:
-    @rm -f "pkg/$(XPI_NAME)"
+    @rm -f    "pkg/$(XPI_NAME)" \
+        "pkg/$(STANDALONE_TARBALL)" \
+        "src/application.ini"


 zip:
     @TMPFILE=/tmp/$(EXT_NAME)-`date '+%Y-%m-%d-%s'`.zip;                     \
diff --git a/application.ini.in b/application.ini.in
new file mode 100644
index 0000000..d655a6e
--- /dev/null
+++ b/application.ini.in
@@ -0,0 +1,13 @@
+[App]
+Vendor=TorProject
+Name=TorLauncher
+Version=__VERSION__
+BuildID=__DATE__
+ID=tor-launcher@???
+
+[Gecko]
+MinVersion=17.0.0
+MaxVersion=*.*.*
+
+[Shell]
+Icon=icon.png
-- 
1.7.10.4


>From a0bc7b077a7da35b34a2a104a7ca09b04aac29c8 Mon Sep 17 00:00:00 2001
From: Tails developers <amnesia@???>
Date: Mon, 17 Feb 2014 20:20:28 +0100
Subject: [PATCH 2/4] Split Tor process starting code from control code.

This separation is useful for supporting configuration of already
started, system-wide Tor instances.
---
 src/chrome/locale/en/torlauncher.properties |    1 +
 src/components/tl-process.js                |   29 ++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)


diff --git a/src/chrome/locale/en/torlauncher.properties b/src/chrome/locale/en/torlauncher.properties
index 483ce43..1221701 100644
--- a/src/chrome/locale/en/torlauncher.properties
+++ b/src/chrome/locale/en/torlauncher.properties
@@ -7,6 +7,7 @@ torlauncher.tor_exited=Tor unexpectedly exited.
torlauncher.please_restart_app=Please restart this application.
torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
torlauncher.tor_failed_to_start=Tor failed to start.
+torlauncher.tor_control_failed=Failed to take control of Tor.
torlauncher.tor_bootstrap_failed=Tor failed to establish a Tor network connection.\n\n%S

 torlauncher.unable_to_start_tor=Unable to start Tor.\n\n%S
diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index 660588d..f04e1e8 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -88,9 +88,13 @@ TorProcessService.prototype =
       this.mObsSvc.addObserver(this, kOpenNetworkSettingsTopic, false);
       this.mObsSvc.addObserver(this, kUserQuitTopic, false);
       this.mObsSvc.addObserver(this, kBootstrapStatusTopic, false);
+      this.mTorProcessStatus = this.kStatusUnknown;


       if (TorLauncherUtil.shouldStartAndOwnTor)
+      {
         this._startTor();
+        this._controlTor();
+      }
     }
     else if ("quit-application-granted" == aTopic)
     {
@@ -261,8 +265,6 @@ TorProcessService.prototype =
   // Private Methods /////////////////////////////////////////////////////////
   _startTor: function()
   {
-    this.mTorProcessStatus = this.kStatusUnknown;
-
     var isInitialBootstrap =
                      TorLauncherUtil.getBoolPref(this.kPrefPromptAtStartup);


@@ -340,7 +342,24 @@ TorProcessService.prototype =
       p.runwAsync(args, args.length, this, false);
       this.mTorProcess = p;
       this.mTorProcessStartTime = Date.now();
+    }
+    catch (e)
+    {
+      this.mTorProcessStatus = this.kStatusExited;
+      var s = TorLauncherUtil.getLocalizedString("tor_failed_to_start");
+      TorLauncherUtil.showAlert(null, s);
+      TorLauncherLogger.safelog(4, "_startTor error: ", e);
+    }
+  }, // _startTor()
+
+
+  _controlTor: function()
+  {
+    var isInitialBootstrap =
+          TorLauncherUtil.getBoolPref(this.kPrefPromptAtStartup);


+    try
+    {
       this._monitorTorProcessStartup();


       if (isInitialBootstrap)
@@ -378,11 +397,11 @@ TorProcessService.prototype =
     catch (e)
     {
       this.mTorProcessStatus = this.kStatusExited;
-      var s = TorLauncherUtil.getLocalizedString("tor_failed_to_start");
+      var s = TorLauncherUtil.getLocalizedString("tor_control_failed");
       TorLauncherUtil.showAlert(null, s);
-      TorLauncherLogger.safelog(4, "_startTor error: ", e);
+      TorLauncherLogger.safelog(4, "_controlTor error: ", e);
     }
-  }, // _startTor()
+  }, // controlTor()


_monitorTorProcessStartup: function()
{
--
1.7.10.4

>From 24fcd3efa440d165a57f703d8013303dc8a2dc97 Mon Sep 17 00:00:00 2001
From: Tails developers <amnesia@???>
Date: Mon, 17 Feb 2014 20:22:29 +0100
Subject: [PATCH 3/4] If TOR_CONFIGURE_ONLY=1, only configure Tor.

This option prevents Tor Launcher from starting a Tor process but it
will try to configure any already started Tor process without taking
ownership of it. This option is intended for situations where Tor
Launcher is supposed to configure an already started, system-wide Tor
instance.

Note that it's not the same as TOR_SKIP_LAUNCH (and, equivalently,
`extensions.torlauncher.start_tor`), which prevents *both* start and
configuration of Tor.
---
 src/components/tl-process.js  |    5 ++++-
 src/components/tl-protocol.js |    3 ++-
 src/modules/tl-util.jsm       |   15 +++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)


diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index f04e1e8..efd1875 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -90,7 +90,10 @@ TorProcessService.prototype =
       this.mObsSvc.addObserver(this, kBootstrapStatusTopic, false);
       this.mTorProcessStatus = this.kStatusUnknown;


-      if (TorLauncherUtil.shouldStartAndOwnTor)
+      if (TorLauncherUtil.shouldOnlyConfigureTor)
+      {
+        this._controlTor();
+      } else if (TorLauncherUtil.shouldStartAndOwnTor)
       {
         this._startTor();
         this._controlTor();
diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index 72530ea..e73f2e9 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -568,7 +568,8 @@ TorProtocolService.prototype =
         return null;
       }


-      if (!aIsEventConnection && TorLauncherUtil.shouldStartAndOwnTor)
+      if (!aIsEventConnection && TorLauncherUtil.shouldStartAndOwnTor &&
+          !TorLauncherUtil.shouldOnlyConfigureTor)
       {
         // 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 e6298e8..c0049fc 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -155,6 +155,21 @@ let TorLauncherUtil =  // Public


     return this.getBoolPref(kPrefStartTor, true);
   },
+
+  get shouldOnlyConfigureTor()
+  {
+    try
+    {
+      const kEnvOnlyConfigureTor = "TOR_CONFIGURE_ONLY";
+
+      var env = Cc["@mozilla.org/process/environment;1"]
+                  .getService(Ci.nsIEnvironment);
+      if (env.exists(kEnvOnlyConfigureTor))
+        return ("1" == env.get(kEnvOnlyConfigureTor));
+    } catch(e) {}
+
+    return false
+  },
 };



--
1.7.10.4

>From a9c0fbedafb3eda7805d48102daae0ad23920297 Mon Sep 17 00:00:00 2001
From: Tails developers <amnesia@???>
Date: Mon, 17 Feb 2014 20:36:20 +0100
Subject: [PATCH 4/4] If FORCE_NET_CONFIG is set, show network settings iff
set to 1.

---
 src/components/tl-process.js |    5 +----
 src/modules/tl-util.jsm      |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)


diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index efd1875..a64f3f9 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -358,14 +358,11 @@ TorProcessService.prototype =

   _controlTor: function()
   {
-    var isInitialBootstrap =
-          TorLauncherUtil.getBoolPref(this.kPrefPromptAtStartup);
-
     try
     {
       this._monitorTorProcessStartup();


-      if (isInitialBootstrap)
+      if (TorLauncherUtil.shouldShowNetworkSettings)
       {
         if (this.mProtocolSvc)
           this._openNetworkSettings(true); // Blocks until dialog is closed.
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index c0049fc..55cb297 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -156,6 +156,22 @@ let TorLauncherUtil =  // Public
     return this.getBoolPref(kPrefStartTor, true);
   },


+  get shouldShowNetworkSettings()
+  {
+    const kPrefPromptAtStartup = "extensions.torlauncher.prompt_at_startup";
+    try
+    {
+      const kEnvForceShowNetConfig = "FORCE_NET_CONFIG";
+
+      var env = Cc["@mozilla.org/process/environment;1"]
+                  .getService(Ci.nsIEnvironment);
+      if (env.exists(kEnvForceShowNetConfig))
+        return ("1" == env.get(kEnvForceShowNetConfig));
+    } catch(e) {}
+
+    return this.getBoolPref(kPrefPromptAtStartup, true);
+  },
+
   get shouldOnlyConfigureTor()
   {
     try
-- 
1.7.10.4