Commit ffb625ed authored by juga's avatar juga
Browse files

Change runtime directory when running supervised

Also go back to use sbws datadir as the default location for the
tor temporal file sockets, because when XDG_RUNTIME_DIR is not
set, the interpolation does not happen.
parent 88258d45
......@@ -58,8 +58,7 @@ max_download_size = 1073741824
[tor]
datadir = ${paths:sbws_home}/tor
# create runtime dir for data that does not need to be persistent
run_dpath = $$XDG_RUNTIME_DIR/sbws
run_dpath = ${datadir}
control_socket = ${tor:run_dpath}/control
pid = ${tor:run_dpath}/tor.pid
# note this is a directory
......
......@@ -28,6 +28,8 @@ DEFAULT_CONFIG_PATH = os.path.join(PKG_DIR, 'config.default.ini')
DEFAULT_LOG_CONFIG_PATH = os.path.join(PKG_DIR, 'config.log.default.ini')
USER_CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.sbws.ini')
SUPERVISED_RUN_DPATH = "/run/sbws/tor"
SOCKET_TIMEOUT = 60 # seconds
SBWS_SCALE_CONSTANT = 7500
......
......@@ -9,7 +9,7 @@ from urllib.parse import urlparse
from string import Template
from tempfile import NamedTemporaryFile
from sbws.globals import (DEFAULT_CONFIG_PATH, DEFAULT_LOG_CONFIG_PATH,
USER_CONFIG_PATH, fail_hard)
USER_CONFIG_PATH, SUPERVISED_RUN_DPATH, fail_hard)
_ALPHANUM = 'abcdefghijklmnopqrstuvwxyz'
_ALPHANUM += _ALPHANUM.upper()
......@@ -217,6 +217,15 @@ def _validate_general(conf):
return errors
def _obtain_run_dpath(conf):
"""Set runtime directory when sbws is run by a system service."""
xdg = os.environ.get('XDG_RUNTIME_DIR')
if os.environ.get('SUPERVISED') == "1":
conf['tor']['run_dpath'] = SUPERVISED_RUN_DPATH
elif xdg is not None:
conf['tor']['run_dpath'] = os.path.join(xdg, 'sbws', 'tor')
def _validate_paths(conf):
errors = []
sec = 'paths'
......@@ -262,6 +271,7 @@ def _validate_scanner(conf):
def _validate_tor(conf):
_obtain_run_dpath(conf)
errors = []
sec = 'tor'
err_tmpl = Template('$sec/$key ($val): $e')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment