summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2018-11-25 17:17:56 -0800
committerMicah Lee <micah@micahflee.com>2018-11-25 17:17:56 -0800
commit49340321445e9b5dcbcded52f72dd16b02dc7a39 (patch)
tree80f205d1a94ac8ede351a3faf2a209cef0cb251d
parent66e50c96b8f63e82edd1bc0a69cc6f62f3ec1728 (diff)
downloadonionshare-49340321445e9b5dcbcded52f72dd16b02dc7a39.tar.gz
onionshare-49340321445e9b5dcbcded52f72dd16b02dc7a39.zip
Make tor data dir always be a tempdir inside OnionShare's data dir
-rw-r--r--onionshare/common.py17
-rw-r--r--onionshare/onion.py9
-rw-r--r--onionshare/settings.py14
3 files changed, 20 insertions, 20 deletions
diff --git a/onionshare/common.py b/onionshare/common.py
index ffa6529f..6b3d85c4 100644
--- a/onionshare/common.py
+++ b/onionshare/common.py
@@ -123,6 +123,23 @@ class Common(object):
return (tor_path, tor_geo_ip_file_path, tor_geo_ipv6_file_path, obfs4proxy_file_path)
+ def build_data_dir(self):
+ """
+ Returns the path of the OnionShare data directory.
+ """
+ if self.platform == 'Windows':
+ try:
+ appdata = os.environ['APPDATA']
+ return '{}\\OnionShare'.format(appdata)
+ except:
+ # If for some reason we don't have the 'APPDATA' environment variable
+ # (like running tests in Linux while pretending to be in Windows)
+ return os.path.expanduser('~/.config/onionshare')
+ elif self.platform == 'Darwin':
+ return os.path.expanduser('~/Library/Application Support/OnionShare')
+ else:
+ return os.path.expanduser('~/.config/onionshare')
+
def build_slug(self):
"""
Returns a random string made from two words from the wordlist, such as "deter-trig".
diff --git a/onionshare/onion.py b/onionshare/onion.py
index 4a94f2ce..7b4f1daa 100644
--- a/onionshare/onion.py
+++ b/onionshare/onion.py
@@ -166,13 +166,8 @@ class Onion(object):
raise BundledTorNotSupported(strings._('settings_error_bundled_tor_not_supported'))
# Create a torrc for this session
- if self.common.platform == 'Darwin':
- group_container_dir = os.path.expanduser('~/Library/Group Containers/com.micahflee.onionshare')
- os.makedirs(group_container_dir, exist_ok=True)
- self.tor_data_directory = tempfile.TemporaryDirectory(dir=group_container_dir)
- self.common.log('Onion', 'connect', 'tor_data_directory={}'.format(self.tor_data_directory.name))
- else:
- self.tor_data_directory = tempfile.TemporaryDirectory()
+ self.tor_data_directory = tempfile.TemporaryDirectory(dir=self.common.build_data_dir())
+ self.common.log('Onion', 'connect', 'tor_data_directory={}'.format(self.tor_data_directory.name))
# Create the torrc
with open(self.common.get_resource_path('torrc_template')) as f:
diff --git a/onionshare/settings.py b/onionshare/settings.py
index 4a056989..058557e9 100644
--- a/onionshare/settings.py
+++ b/onionshare/settings.py
@@ -120,19 +120,7 @@ class Settings(object):
"""
Returns the path of the settings file.
"""
- p = platform.system()
- if p == 'Windows':
- try:
- appdata = os.environ['APPDATA']
- return '{}\\OnionShare\\onionshare.json'.format(appdata)
- except:
- # If for some reason we don't have the 'APPDATA' environment variable
- # (like running tests in Linux while pretending to be in Windows)
- return os.path.expanduser('~/.config/onionshare/onionshare.json')
- elif p == 'Darwin':
- return os.path.expanduser('~/Library/Application Support/OnionShare/onionshare.json')
- else:
- return os.path.expanduser('~/.config/onionshare/onionshare.json')
+ return os.path.join(self.common.build_data_dir(), 'onionshare.json')
def build_default_downloads_dir(self):
"""