summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-11-04 15:22:27 -0800
committerMicah Lee <micah@micahflee.com>2020-11-04 15:22:27 -0800
commitd9153758cdfb44b7ff37068d39c33161aea0e227 (patch)
treea16634325c2b950a23f44c69e6c82b9496b6c43d
parent68347039c9547d0190e6809780e372d43f5a890b (diff)
downloadonionshare-d9153758cdfb44b7ff37068d39c33161aea0e227.tar.gz
onionshare-d9153758cdfb44b7ff37068d39c33161aea0e227.zip
Find the proper tor binary in onionshare-cli for macOS
-rw-r--r--cli/onionshare_cli/common.py31
-rw-r--r--cli/onionshare_cli/onion.py4
2 files changed, 24 insertions, 11 deletions
diff --git a/cli/onionshare_cli/common.py b/cli/onionshare_cli/common.py
index 0c034a87..1174d8e8 100644
--- a/cli/onionshare_cli/common.py
+++ b/cli/onionshare_cli/common.py
@@ -93,17 +93,26 @@ class Common:
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")
elif self.platform == "Darwin":
- base_path = os.path.dirname(
- os.path.dirname(os.path.dirname(self.get_resource_path("")))
- )
- 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"
- )
+ if os.path.basename(sys.argv[0]) == "onionshare-cli":
+ tor_path = shutil.which("tor")
+ obfs4proxy_file_path = shutil.which("obfs4proxy")
+ prefix = os.path.dirname(os.path.dirname(tor_path))
+ tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
+ tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
+ else:
+ base_path = os.path.dirname(
+ os.path.dirname(os.path.dirname(self.get_resource_path("")))
+ )
+ 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":
tor_path = "/usr/local/bin/tor"
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
diff --git a/cli/onionshare_cli/onion.py b/cli/onionshare_cli/onion.py
index 02fd3263..6a42638a 100644
--- a/cli/onionshare_cli/onion.py
+++ b/cli/onionshare_cli/onion.py
@@ -328,6 +328,10 @@ class Onion(object):
f.write(self.settings.get("tor_bridges_use_custom_bridges"))
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
start_ts = time.time()
if self.common.platform == "Windows":