[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/master] fix: torrc validation case sensetive
commit e7e4bb5a9a39857436620f71edba9092ff963247
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Dec 7 09:17:29 2011 -0800
fix: torrc validation case sensetive
The torrc validation is case sensetive using tor's camelcase convention, but
tor's torrc parsing is case insensetive. This caused confusing torrc warnings
where, for instance, "Exitpolicy" would be reported as both being unused and
also missing an "ExitPolicy" option. Reported in...
https://trac.torproject.org/projects/tor/ticket/4601
This fix is functional but less than ideal since it makes the case
insensetivity non-obvious (we're essentially converting the torrc arguments
into the camelcase options we expect). I'll look into doing something nicer
while refactoring for stem.
Issue was caught on a Tor Cloud instance by kooly
---
src/util/torConfig.py | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/src/util/torConfig.py b/src/util/torConfig.py
index e26f634..851ef77 100644
--- a/src/util/torConfig.py
+++ b/src/util/torConfig.py
@@ -531,6 +531,21 @@ def validate(contents = None):
if len(lineComp) == 2: option, value = lineComp
else: option, value = lineText, ""
+ # Tor is case insensetive when parsing its torrc. This poses a bit of an
+ # issue for us because we want all of our checks to be case insensetive
+ # too but also want messages to match the normal camel-case conventions.
+ #
+ # Using the customOptions to account for this. It contains the tor reported
+ # options (camel case) and is either a matching set or the following defaut
+ # value check will fail. Hence using that hash to correct the case.
+ #
+ # TODO: when refactoring for stem make this less confusing...
+
+ for customOpt in customOptions:
+ if customOpt.lower() == option.lower():
+ option = customOpt
+ break
+
# if an aliased option then use its real name
if option in CONFIG["torrc.alias"]:
option = CONFIG["torrc.alias"][option]
@@ -787,7 +802,9 @@ class Torrc():
skipValidation = not CONFIG["features.torrc.validate"]
skipValidation |= not torTools.getConn().isVersion("0.2.2.7-alpha")
- if skipValidation: returnVal = {}
+ if skipValidation:
+ log.log(log.INFO, "Skipping torrc validation (requires tor 0.2.2.7-alpha)")
+ returnVal = {}
else:
if self.corrections == None:
self.corrections = validate(self.contents)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits