Commit 29dee257 authored by anonym's avatar anonym
Browse files

tor-controlport-filter: deal with bad YAML.

parent cad3d9aa
...@@ -438,13 +438,17 @@ class FilteredControlPortProxyHandler(socketserver.StreamRequestHandler): ...@@ -438,13 +438,17 @@ class FilteredControlPortProxyHandler(socketserver.StreamRequestHandler):
super(type(self), self).setup() super(type(self), self).setup()
self.filters = [] self.filters = []
for filter_file in glob.glob('/etc/tor-controlport-filter.d/*.yml'): for filter_file in glob.glob('/etc/tor-controlport-filter.d/*.yml'):
with open(filter_file, "rb") as fh: try:
filters = yaml.load( with open(filter_file, "rb") as fh:
name = re.sub(r'\.yml$', '', os.path.basename(filter_file)) filters = yaml.load(
for filter_ in filters: name = re.sub(r'\.yml$', '', os.path.basename(filter_file))
if name not in filter_: for filter_ in filters:
filter_['name'] = name if name not in filter_:
self.filters += filters filter_['name'] = name
self.filters += filters
except (yaml.parser.ParserError, yaml.scanner.ScannerError):
log("filter '{}' has bad YAML and was not loaded!"
def connect_to_real_control_port(self): def connect_to_real_control_port(self):
with open(global_args.control_cookie_path, "rb") as f: with open(global_args.control_cookie_path, "rb") as f:
Markdown is supported
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