Skip to content

Don't connect to Tor if it's already running

akwizgran requested to merge 578-tor-ports into master

For some time now we've had a reliable way of shutting down the Tor process (the __OwningControllerProcess command line argument combined with the TAKEOWNERSHIP command), but TorPlugin#start() still assumes that Tor may already be running. This allows another app to bind the Tor control and SOCKS ports and collect confidential data from Briar (#578 (closed)). It also allows two Briar instances running on the same device to try to communicate with the same Tor process, which prevents proper shutdown (#572 (closed)).

This patch prevents the Tor plugin from starting unless it's able to start its own Tor process with the expected control and SOCKS ports. If two Briar instances are running on the same device, only one of them will be able to use Tor. The other should fail to start its Tor plugin and then function normally without Tor access, including normal shutdown.

Fixes #572 (closed), #578 (closed). Open another ticket if you want two Briar instances on the same device to have their own Tor processes. :-)

Merge request reports