Find the proper tor binary in onionshare-cli for macOS

This commit is contained in:
Micah Lee 2020-11-04 15:22:27 -08:00
parent 68347039c9
commit d9153758cd
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 24 additions and 11 deletions

View File

@ -93,17 +93,26 @@ class Common:
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip") tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6") tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
elif self.platform == "Darwin": elif self.platform == "Darwin":
base_path = os.path.dirname( if os.path.basename(sys.argv[0]) == "onionshare-cli":
os.path.dirname(os.path.dirname(self.get_resource_path(""))) tor_path = shutil.which("tor")
) obfs4proxy_file_path = shutil.which("obfs4proxy")
tor_path = os.path.join(base_path, "Resources", "Tor", "tor") prefix = os.path.dirname(os.path.dirname(tor_path))
tor_geo_ip_file_path = os.path.join(base_path, "Resources", "Tor", "geoip") tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
tor_geo_ipv6_file_path = os.path.join( tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
base_path, "Resources", "Tor", "geoip6" else:
) base_path = os.path.dirname(
obfs4proxy_file_path = os.path.join( os.path.dirname(os.path.dirname(self.get_resource_path("")))
base_path, "Resources", "Tor", "obfs4proxy" )
) tor_path = os.path.join(base_path, "Resources", "Tor", "tor")
tor_geo_ip_file_path = os.path.join(
base_path, "Resources", "Tor", "geoip"
)
tor_geo_ipv6_file_path = os.path.join(
base_path, "Resources", "Tor", "geoip6"
)
obfs4proxy_file_path = os.path.join(
base_path, "Resources", "Tor", "obfs4proxy"
)
elif self.platform == "BSD": elif self.platform == "BSD":
tor_path = "/usr/local/bin/tor" tor_path = "/usr/local/bin/tor"
tor_geo_ip_file_path = "/usr/local/share/tor/geoip" tor_geo_ip_file_path = "/usr/local/share/tor/geoip"

View File

@ -328,6 +328,10 @@ class Onion(object):
f.write(self.settings.get("tor_bridges_use_custom_bridges")) f.write(self.settings.get("tor_bridges_use_custom_bridges"))
f.write("\nUseBridges 1") f.write("\nUseBridges 1")
# Make sure the tor path is accurate
if not os.path.exists(self.tor_path):
raise BundledTorNotSupported(f"Cannot find tor binary: {self.tor_path}")
# Execute a tor subprocess # Execute a tor subprocess
start_ts = time.time() start_ts = time.time()
if self.common.platform == "Windows": if self.common.platform == "Windows":