commit c94f7669daecea8994561e25e7f2c3ed6f44d478 Author: Damian Johnson atagar@torproject.org Date: Wed Jul 20 07:44:23 2011 -0700
fix: writing blank torrc without GETINFO option
When "GETINFO config-text" we save a blank torrc rather than providing the user with an error. This option was introduced in Tor 0.2.2.7. Caught by Runa (https://trac.torproject.org/projects/tor/ticket/3614). --- src/util/torConfig.py | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/util/torConfig.py b/src/util/torConfig.py index e4570ca..557dc09 100644 --- a/src/util/torConfig.py +++ b/src/util/torConfig.py @@ -415,6 +415,19 @@ def saveConf(destination = None, contents = None): if not contents: contents = currentConfig else: isSaveconf &= contents == currentConfig
+ # The "GETINFO config-text" option was introduced in Tor version 0.2.2.7. If + # we're writing custom contents then this is fine, but if we're trying to + # save the current configuration then we need to fail if it's unavailable. + # Otherwise we'd write a blank torrc as per... + # https://trac.torproject.org/projects/tor/ticket/3614 + + if contents == ['']: + # double check that "GETINFO config-text" is unavailable rather than just + # giving an empty result + + if torTools.getConn().getInfo("config-text") == None: + raise IOError("determining the torrc requires Tor version 0.2.2.7") + currentLocation = None try: currentLocation = getConfigLocation()
tor-commits@lists.torproject.org