torbrowser-launcher
torbrowser-launcher copied to clipboard
[WIP] Open additional URLs with the same TorBrowser instance
When we looked at the history of issues about opening links with TorBrowser, we found #103 where initially the feature to open links from other applications was added. Then some months later, the feature was removed again, as it was not working because of #157 and #175. The issues was back then (~4years ago), that when users had a normal Firefox running, urls got opened in the normal firefox insead of TorBrowser. That was because TorBrowser had the --no-remote flag set deep down in their code. In the meanwhile TorBrowser removed the explicit --no-remote flag, so we are able to use --allow-remote again. On top of that there is another issue when we want open urls with TorBrowser: If the LOGNAME is the same as the LOGNAME of the opened firefox, urls are still opened in the open firefox. But if we set the LOGNAME envrionment variable explicitly, we can make sure, that the url opens in the TorBrowser instead of a running Firefox.
Should fix: #245, #259, #380
WIP: it is not cleaned up, maybe we want revert 3f1146e1a084c4e8021da968104cbc2877ae01e6 and have the setting accept_links back.
I think this would solve number of open Debian bugs, such as https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=910062 and friends :)
You would need to add -allow-remote to the "Browser/firefox" script but only for the first launch. Otherwise you get multiple windows. Basically as -allow-remote is not passed by "torbrowser-launcher" (invalid option).
Regardless. torbrowser is always launched with the startup pages for each new window. The URL argument to "torbrowser-launcher" is basically completely ignored.
Really torbrowser needs to have some way of opening a specified URL, both on the initial window, and in a currently running browser. It has been asked for for years!
You would need to add -allow-remote to the "Browser/firefox" script but only for the first launch. Otherwise you get multiple windows. Basically as -allow-remote is not passed by "torbrowser-launcher" (invalid option).
I can't reproduce your described behavior, did you tested my patch? I run my patch since March locally and it works. I don't get new windows every time I open links.
Regardless. torbrowser is always launched with the startup pages for each new window. The URL argument to "torbrowser-launcher" is basically completely ignored.
as it described in my initial description, this is not true anymore, that's why this patch is enough and no need to change anything in Tor Browser.
Really torbrowser needs to have some way of opening a specified URL, both on the initial window, and in a currently running browser. It has been asked for for years!
To be able to open multiple windows, we need to pass the new-window/new-tab command lines to start-tor-browser, but that's a different patch, after that got accepted.
I run my patch since March locally and it works. I don't get new windows every time I open links.
I tried adding it... Got python errors. I don't know python, (though I am an old - 30yo programmer - sh perl, c, not python) and this is a system installed package! I assume I would have to 'compile' the ".py" file to "py[co]" files.
...
File "/usr/lib/python2.7/site-packages/torbrowser_launcher/launcher.py", line 441, in run
subprocess.call([self.common.paths['tbb']['start'], '--allow-remote', self.url_list], cwd=self.common.paths['tbb']['dir_tbb'], env=my_env)
File "/usr/lib64/python2.7/subprocess.py", line 172, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
TypeError: coercing to Unicode: need string or buffer, list found
I run my patch since March locally and it works. I don't get new windows every time I open links.
I tried adding it... Got python errors. I don't know python, (though I am an old - 30yo programmer - sh perl, c, not python) and this is a system installed package! I assume I would have to 'compile' the ".py" file to "py[co]" files.
nope you don't have to 'compile' it on your own. It is compiled, when you first need the file.
... File "/usr/lib/python2.7/site-packages/torbrowser_launcher/launcher.py", line 441, in run subprocess.call([self.common.paths['tbb']['start'], '--allow-remote', self.url_list], cwd=self.common.paths['tbb']['dir_tbb'], env=my_env) File "/usr/lib64/python2.7/subprocess.py", line 172, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib64/python2.7/subprocess.py", line 394, in __init__ errread, errwrite) File "/usr/lib64/python2.7/subprocess.py", line 1047, in _execute_child raise child_exception TypeError: coercing to Unicode: need string or buffer, list found
The issue is that python2 (EOF 1.Jan 2020) is used to run torbrowser-launcher and not python3. Not every distribution is using a symlink python -> python3, but every distribution should have installed python3. If you run the code with python3 it works.
Or replace the following to be python2 complainant:
- subprocess.call([self.common.paths['tbb']['start'], '--allow-remote', self.url_list], cwd=self.common.paths['tbb']['dir_tbb'], env=my_env)
+ subprocess.call([self.common.paths['tbb']['start'], '--allow-remote'] + self.url_list, cwd=self.common.paths['tbb']['dir_tbb'], env=my_env)
as stated in upstream ticket: https://trac.torproject.org/projects/tor/ticket/15185#comment:2
default "--no-remote" is set for good reason. it makes less footprint on the host TBB is running. we need to find other better way to open URL from command line under "--no-remote" setting. better not to merge this patch.