[or-cvs] r24058: {arm} Including platform and arm/tor configurations in debug dumps (in arm/trunk: . src)

Damian Johnson atagar1 at gmail.com
Mon Jan 10 17:09:13 UTC 2011


Author: atagar
Date: 2011-01-10 17:09:13 +0000 (Mon, 10 Jan 2011)
New Revision: 24058

Modified:
   arm/trunk/ChangeLog
   arm/trunk/TODO
   arm/trunk/armrc.sample
   arm/trunk/src/starter.py
   arm/trunk/src/version.py
Log:
Including platform and arm/tor configurations in debug dumps.



Modified: arm/trunk/ChangeLog
===================================================================
--- arm/trunk/ChangeLog	2011-01-10 12:45:42 UTC (rev 24057)
+++ arm/trunk/ChangeLog	2011-01-10 17:09:13 UTC (rev 24058)
@@ -1,6 +1,6 @@
 CHANGE LOG
 
-1/7/11 - version 1.4.1
+1/7/11 - version 1.4.1 (r24054)
 Platform specific enhancements including BSD compatibility and vastly improved performance on Linux.
 
     * added: querying the proc contents when able for tor resource and connection samplings to *greatly* reduce arm's resource usage (many thanks to psutil)

Modified: arm/trunk/TODO
===================================================================
--- arm/trunk/TODO	2011-01-10 12:45:42 UTC (rev 24057)
+++ arm/trunk/TODO	2011-01-10 17:09:13 UTC (rev 24058)
@@ -85,6 +85,7 @@
 
 - Bugs
   * The default resolver isn't configurable.
+  * When saving the config the Log entry should be filtered out if unnecessary.
   * The config write dialog (ie, the one for saving the config) has its a
     misaligned border when it's smaller than the top detail section.
   * The arm header panel doesn't properly reflect when the ip address

Modified: arm/trunk/armrc.sample
===================================================================
--- arm/trunk/armrc.sample	2011-01-10 12:45:42 UTC (rev 24057)
+++ arm/trunk/armrc.sample	2011-01-10 17:09:13 UTC (rev 24058)
@@ -227,4 +227,5 @@
 log.stats.failedProcResolution DEBUG
 log.stats.procResolutionFailover INFO
 log.stats.failedPsResolution INFO
+log.savingDebugLog NOTICE
 

Modified: arm/trunk/src/starter.py
===================================================================
--- arm/trunk/src/starter.py	2011-01-10 12:45:42 UTC (rev 24057)
+++ arm/trunk/src/starter.py	2011-01-10 17:09:13 UTC (rev 24058)
@@ -11,6 +11,7 @@
 import time
 import getopt
 import socket
+import platform
 
 import version
 import interface.controller
@@ -44,7 +45,8 @@
           "log.configDescriptions.persistance.loadSuccess": util.log.INFO,
           "log.configDescriptions.persistance.loadFailed": util.log.INFO,
           "log.configDescriptions.persistance.saveSuccess": util.log.INFO,
-          "log.configDescriptions.persistance.saveFailed": util.log.NOTICE}
+          "log.configDescriptions.persistance.saveFailed": util.log.NOTICE,
+          "log.savingDebugLog": util.log.NOTICE}
 
 OPT = "i:c:dbe:vh"
 OPT_EXPANDED = ["interface=", "config=", "debug", "blind", "event=", "version", "help"]
@@ -83,6 +85,9 @@
 STANDARD_CFG_LOAD_FAILED_MSG = "Failed to load configuration (using defaults): \"%s\""
 STANDARD_CFG_NOT_FOUND_MSG = "No configuration found at '%s', using defaults"
 
+# torrc entries that are scrubbed when dumping
+PRIVATE_TORRC_ENTRIES = ["HashedControlPassword", "Bridge", "HiddenServiceDir"]
+
 def isValidIpAddr(ipStr):
   """
   Returns true if input is a valid IPv4 address, false otherwise.
@@ -179,6 +184,47 @@
         msg = DESC_INTERNAL_LOAD_FAILED_MSG % util.sysTools.getFileErrorMsg(exc)
         util.log.log(CONFIG["log.configDescriptions.internalLoadFailed"], msg)
 
+def _dumpConfig():
+  """
+  Dumps the current arm and tor configurations at the DEBUG runlevel. This
+  attempts to scrub private information, but naturally the user should double
+  check that I didn't miss anything.
+  """
+  
+  config = util.conf.getConfig("arm")
+  conn = util.torTools.getConn()
+  
+  # dumps arm's configuration
+  armConfigEntry = ""
+  armConfigKeys = list(config.getKeys())
+  armConfigKeys.sort()
+  
+  for configKey in armConfigKeys:
+    # Skips some config entries that are loaded by default. This fetches
+    # the config values directly to avoid misflagging them as being used by
+    # arm.
+    
+    if not configKey.startswith("config.summary.") and not configKey.startswith("torrc.") and not configKey.startswith("msg."):
+      armConfigEntry += "%s -> %s\n" % (configKey, config.contents[configKey])
+  
+  if armConfigEntry: armConfigEntry = "Arm Configuration:\n%s" % armConfigEntry
+  else: armConfigEntry = "Arm Configuration: None"
+  
+  # dumps tor's version and configuration
+  torConfigEntry = "Tor (%s) Configuration:\n" % conn.getInfo("version")
+  
+  for line in conn.getInfo("config-text").split("\n"):
+    if " " in line: key, value = line.split(" ", 1)
+    else: key, value = line, ""
+    
+    if key in PRIVATE_TORRC_ENTRIES:
+      torConfigEntry += "%s <scrubbed>\n" % key
+    else:
+      torConfigEntry += "%s %s\n" % (key, value)
+  
+  util.log.log(util.log.DEBUG, armConfigEntry.strip())
+  util.log.log(util.log.DEBUG, torConfigEntry.strip())
+
 if __name__ == '__main__':
   startTime = time.time()
   param = dict([(key, None) for key in CONFIG.keys()])
@@ -230,8 +276,9 @@
       currentTime = time.localtime()
       timeLabel = time.strftime("%H:%M:%S %m/%d/%Y (%Z)", currentTime)
       initMsg = "Arm %s Debug Dump, %s" % (version.VERSION, timeLabel)
+      osLabel = "Platform: %s (%s)" % (platform.system(), " ".join(platform.dist()))
       
-      util.log.DUMP_FILE.write("%s\n%s\n" % (initMsg, "-" * len(initMsg)))
+      util.log.DUMP_FILE.write("%s\n%s\n%s\n" % (initMsg, osLabel, "-" * 80))
       util.log.DUMP_FILE.flush()
     except (OSError, IOError), exc:
       print "Unable to write to debug log file: %s" % util.sysTools.getFileErrorMsg(exc)
@@ -355,6 +402,11 @@
   # fetches descriptions for tor's configuration options
   _loadConfigurationDescriptions(pathPrefix)
   
+  # dump tor and arm configuration when in debug mode
+  if isDebugMode:
+    util.log.log(CONFIG["log.savingDebugLog"], "Saving a debug log to '%s' (please check it for sensitive information before sharing)" % LOG_DUMP_PATH)
+    _dumpConfig()
+  
   interface.controller.startTorMonitor(time.time() - initTime, expandedEvents, param["startup.blindModeEnabled"])
   conn.close()
 

Modified: arm/trunk/src/version.py
===================================================================
--- arm/trunk/src/version.py	2011-01-10 12:45:42 UTC (rev 24057)
+++ arm/trunk/src/version.py	2011-01-10 17:09:13 UTC (rev 24058)
@@ -2,6 +2,6 @@
 Provides arm's version and release date.
 """
 
-VERSION = '1.4.1'
+VERSION = '1.4.1_dev'
 LAST_MODIFIED = "January 7, 2011"
 



More information about the tor-commits mailing list