Create a group container for macOS sandbox, and on Mac put the Tor data dir in it

This commit is contained in:
Micah Lee 2018-11-25 16:15:27 -08:00
parent 0794d7fb90
commit d8b873a208
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 13 additions and 6 deletions

View File

@ -4,6 +4,8 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
@ -12,5 +14,9 @@
<array>
<string>/OnionShare</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>com.micahflee.onionshare</string>
</array>
</dict>
</plist>

View File

@ -166,7 +166,12 @@ class Onion(object):
raise BundledTorNotSupported(strings._('settings_error_bundled_tor_not_supported'))
# Create a torrc for this session
self.tor_data_directory = tempfile.TemporaryDirectory()
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)
else:
self.tor_data_directory = tempfile.TemporaryDirectory()
if self.common.platform == 'Windows':
# Windows needs to use network ports, doesn't support unix sockets

View File

@ -163,11 +163,7 @@ class Settings(object):
Save settings to file.
"""
self.common.log('Settings', 'save')
try:
os.makedirs(os.path.dirname(self.filename))
except:
pass
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
open(self.filename, 'w').write(json.dumps(self._settings))
self.common.log('Settings', 'save', 'Settings saved in {}'.format(self.filename))