From 347d6ab19f911b12b6274f365cf9b2a6b122f37b Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 27 Nov 2019 14:54:41 -0800 Subject: [PATCH 1/2] Make Common.get_resource_path find the resource path relative to the binary, instead of using an absolute path --- onionshare/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/onionshare/common.py b/onionshare/common.py index d97f0ccb..48f52098 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -97,8 +97,10 @@ class Common(object): ) elif self.platform == "BSD" or self.platform == "Linux": - # Assume OnionShare is installed systemwide in Linux, since we're not running in dev mode - prefix = os.path.join(sys.prefix, "share/onionshare") + # Look for resources relative to the binary, so if the binary is /usr/bin/onionshare-gui and + # the resource dir is /usr/share/onionshare, then the resource dir relative to the binary dir + # is ../share/onionshare + prefix = os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), "share/onionshare") elif getattr(sys, "frozen", False): # Check if app is "frozen" From e253b065492ddc68df8ea43ba8a9458a60f45ecc Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 27 Nov 2019 15:41:37 -0800 Subject: [PATCH 2/2] Update tor paths to use paths relative to the binary, instead of absolute paths --- onionshare/common.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/onionshare/common.py b/onionshare/common.py index 48f52098..e447ea34 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -114,10 +114,11 @@ class Common(object): def get_tor_paths(self): if self.platform == "Linux": - tor_path = "/usr/bin/tor" - tor_geo_ip_file_path = "/usr/share/tor/geoip" - tor_geo_ipv6_file_path = "/usr/share/tor/geoip6" - obfs4proxy_file_path = "/usr/bin/obfs4proxy" + prefix = os.path.dirname(os.path.dirname(sys.argv[0])) + tor_path = os.path.join(prefix, "bin/tor") + tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") + tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") + obfs4proxy_file_path = os.path.join(prefix, "bin/obfs4proxy") elif self.platform == "Windows": base_path = os.path.join( os.path.dirname(os.path.dirname(self.get_resource_path(""))), "tor"