Merge pull request #839 from micahflee/837_2.x_cve-2018-19960

Change filename of flask debug log to be in ~/.config/onionshare, not /tmp
This commit is contained in:
Micah Lee 2018-12-11 12:50:47 -08:00 committed by GitHub
commit aa5fdde6a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,9 +184,20 @@ class Web(object):
"""
Turn on debugging mode, which will log flask errors to a debug file.
"""
temp_dir = tempfile.gettempdir()
log_handler = logging.FileHandler(
os.path.join(temp_dir, 'onionshare_server.log'))
if self.common.platform == 'Windows':
try:
appdata = os.environ['APPDATA']
flask_debug_filename = '{}\\OnionShare\\flask_debug.log'.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)
flask_debug_filename = os.path.expanduser('~/.config/onionshare/flask_debug.log')
elif self.common.platform == 'Darwin':
flask_debug_filename = os.path.expanduser('~/Library/Application Support/OnionShare/flask_debug.log')
else:
flask_debug_filename = os.path.expanduser('~/.config/onionshare/flask_debug.log')
log_handler = logging.FileHandler(flask_debug_filename)
log_handler.setLevel(logging.WARNING)
self.app.logger.addHandler(log_handler)