Please understand, the problem is not, to run multiple Tor Browsers as the same user. The problem is to run multiple Tor Browsers, each from a different user at the same time on the same machine.

After investigation I found, that this is because of a fixed SOCKSPORT and and fixed CONTROLPORT.
But each user needs his own SOCKSPORT and CONTROLPORT.

To fix this, the upstream script which is installed at ~/.local/share/torbrowser/tbb/x86_64/tor-browser_de/Browser/start-tor-browser has to be changed for each user. The patch is attached.

The patch first searches for free ports and then modifies the config files to use the free ports.

I have build a wrapper script for torbrowser-launcher to apply the patch, if it isn't already applied.
But I hope it will be fixed by upstream.



--- start-tor-browser.org	2017-05-26 19:55:30.120192846 +0000
+++ start-tor-browser	2017-05-26 19:58:31.671710018 +0000
@@ -164,6 +164,31 @@
     detach=0
 fi
 
+# Use free ports as SOCKSPORT and CONTROLPORT
+GREPUSEDPORTS=$(netstat -na |
+  sed -n "s/^tcp\s\+\S\+\s\+\S\+\s\+127.0.0.1:\(\S\+\)\s.*$/-e \"\\\\<\1\\\\>\"/p" |
+  awk '{printf("%s ",$0)}' )
+FREEPORTS="$(seq 9150 9190 | eval "grep -v $GREPUSEDPORTS" | head -2)"
+if [ $(echo "$FREEPORTS" | wc -l) -ne 2 ]; then
+   complain "No Free ports for found in range from 9150 to 9190 for SocksPort and ControlPort" 
+   exit 1
+fi
+SOCKSPORT="$(echo "$FREEPORTS" | head -1)"
+CONTROLPORT="$(echo "$FREEPORTS" | tail -1)"
+echo "Using SOCKSPORT=<$SOCKSPORT> and CONTROLPORT=<$CONTROLPORT> pwd=<$(/bin/pwd)>." >&2
+PREFS="$(cat Browser/TorBrowser/Data/Browser/profile.default/prefs.js |
+  grep -v -e "extensions.torlauncher.control_port" -e "extensions.torbutton.custom.socks_port" \
+  -e "extensions.torbutton.custom.socks_host" -e "network.proxy.socks_port")"
+cat <<END > Browser/TorBrowser/Data/Browser/profile.default/prefs.js
+$PREFS
+user_pref("extensions.torlauncher.control_port",$CONTROLPORT);
+user_pref("extensions.torbutton.custom.socks_port",$SOCKSPORT);
+user_pref("extensions.torbutton.custom.socks_host","127.0.0.1");
+user_pref("network.proxy.socks_port",$SOCKSPORT);
+END
+sed -i "s/^SocksPort\s\+\S\+/SocksPort $SOCKSPORT/" Browser/TorBrowser/Data/Tor/torrc-defaults
+sed -i "s/^ControlPort\s\+\S\+/ControlPort $CONTROLPORT/" Browser/TorBrowser/Data/Tor/torrc-defaults
+
 if [ "$show_output" -eq 0 ]; then
     # If the user hasn't requested 'debug mode' or --help, close stdout and stderr,
     # to keep Firefox and the stuff loaded by/for it (including the

Attachment: binaBhP2iA4Dx.bin
Description: Öffentlicher PGP-Schlüssel

Reply via email to