Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
3d31263b
Commit
3d31263b
authored
Oct 31, 2018
by
juga
Browse files
Change configuration path when running supervised
parent
ffb625ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
sbws/globals.py
View file @
3d31263b
...
...
@@ -27,7 +27,7 @@ PKG_DIR = os.path.abspath(os.path.dirname(__file__))
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_USER_CONFIG_PATH
=
"/etc/sbws/sbws.ini"
SUPERVISED_RUN_DPATH
=
"/run/sbws/tor"
SOCKET_TIMEOUT
=
60
# seconds
...
...
sbws/util/config.py
View file @
3d31263b
...
...
@@ -9,7 +9,8 @@ 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
,
SUPERVISED_RUN_DPATH
,
fail_hard
)
USER_CONFIG_PATH
,
SUPERVISED_RUN_DPATH
,
SUPERVISED_USER_CONFIG_PATH
,
fail_hard
)
_ALPHANUM
=
'abcdefghijklmnopqrstuvwxyz'
_ALPHANUM
+=
_ALPHANUM
.
upper
()
...
...
@@ -47,6 +48,12 @@ def _get_default_config():
return
_extend_config
(
conf
,
DEFAULT_CONFIG_PATH
)
def
_obtain_user_conf_path
():
if
os
.
environ
.
get
(
"SUPERVISED"
)
==
"1"
:
return
SUPERVISED_USER_CONFIG_PATH
return
USER_CONFIG_PATH
def
_get_user_config
(
args
,
conf
=
None
):
"""Get user configuration.
Search for user configuration in the default path or the path passed as
...
...
@@ -61,8 +68,9 @@ def _get_user_config(args, conf=None):
if
not
os
.
path
.
isfile
(
args
.
config
):
fail_hard
(
'Configuration file %s not found.'
,
args
.
config
)
return
_extend_config
(
conf
,
args
.
config
)
if
os
.
path
.
isfile
(
USER_CONFIG_PATH
):
return
_extend_config
(
conf
,
USER_CONFIG_PATH
)
user_config_path
=
_obtain_user_conf_path
()
if
os
.
path
.
isfile
(
user_config_path
):
return
_extend_config
(
conf
,
user_config_path
)
log
.
debug
(
'No user config found.'
)
return
conf
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment