[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r23422: {arm} added: providing a path prefix config option for chroot jail (in arm/trunk/src: . interface interface/graphing util)



Author: atagar
Date: 2010-10-06 16:19:49 +0000 (Wed, 06 Oct 2010)
New Revision: 23422

Modified:
   arm/trunk/src/armrc.defaults
   arm/trunk/src/interface/confPanel.py
   arm/trunk/src/interface/graphing/bandwidthStats.py
   arm/trunk/src/interface/logPanel.py
   arm/trunk/src/util/torTools.py
Log:
added: providing a path prefix config option for chroot jails (feature request by asn)
fix: more common debug/info messages for deduplication



Modified: arm/trunk/src/armrc.defaults
===================================================================
--- arm/trunk/src/armrc.defaults	2010-10-06 15:22:35 UTC (rev 23421)
+++ arm/trunk/src/armrc.defaults	2010-10-06 16:19:49 UTC (rev 23422)
@@ -13,10 +13,13 @@
 # Renders the interface with color if set and the terminal supports it
 features.colorInterface true
 
+# Set this if you're running in a chroot jail or other environment where tor's
+# resources (log, state, etc) have an unreported prefix in their path.
+features.pathPrefix
+
 # If set, arm appends any log messages it reports while running to the given
 # log file. This does not take filters into account or include prepopulated
 # events.
-
 features.logFile 
 
 # Paremters for the log panel
@@ -134,6 +137,7 @@
 log.torGetInfo DEBUG
 log.torGetConf DEBUG
 log.torEventTypeUnrecognized NOTICE
+log.torPrefixPathInvalid NOTICE
 log.sysCallMade DEBUG
 log.sysCallCached NONE
 log.sysCallFailed INFO
@@ -166,8 +170,13 @@
 # [BW] READ: 0, WRITTEN: 0
 # [DEBUG] connection_handle_write(): After TLS write of 512: 0 read, 586 written
 # [DEBUG] flush_chunk_tls(): flushed 512 bytes, 0 ready to flush, 0 remain.
+# [DEBUG] conn_read_callback(): socket 7 wants to read.
 # [DEBUG] conn_write_callback(): socket 51 wants to write.
+# [DEBUG] connection_remove(): removing socket -1 (type OR), n_conns now 50
 # [DEBUG] connection_or_process_cells_from_inbuf(): 7: starting, inbuf_datalen 0 (0 pending in tls object).
+# [DEBUG] connection_read_to_buf(): 38: starting, inbuf_datalen 0 (0 pending in tls object). at_most 12800.
+# [DEBUG] connection_read_to_buf(): TLS connection closed on read. Closing. (Nickname moria1, address 128.31.0.34)
+# [INFO] run_connection_housekeeping(): Expiring non-open OR connection to fd 16 (79.193.61.171:443).
 # [INFO] rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of 0.950000
 # [NOTICE] We stalled too much while trying to write 150 bytes to address
 #          [scrubbed].  If this happens a lot, either something is wrong with
@@ -193,8 +202,13 @@
 msg.BW READ:
 msg.DEBUG connection_handle_write(): After TLS write of
 msg.DEBUG flush_chunk_tls(): flushed
+msg.DEBUG conn_read_callback(): socket
 msg.DEBUG conn_write_callback(): socket
+msg.DEBUG connection_remove(): removing socket
 msg.DEBUG connection_or_process_cells_from_inbuf():
+msg.DEBUG *pending in tls object). at_most
+msg.DEBUG connection_read_to_buf(): TLS connection closed on read. Closing.
+msg.INFO run_connection_housekeeping(): Expiring
 msg.INFO rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of
 msg.NOTICE We stalled too much while trying to write
 msg.NOTICE I learned some more directory information, but not enough to build a circuit

Modified: arm/trunk/src/interface/confPanel.py
===================================================================
--- arm/trunk/src/interface/confPanel.py	2010-10-06 15:22:35 UTC (rev 23421)
+++ arm/trunk/src/interface/confPanel.py	2010-10-06 16:19:49 UTC (rev 23422)
@@ -8,7 +8,7 @@
 
 import controller
 from TorCtl import TorCtl
-from util import log, panel, uiTools
+from util import log, panel, torTools, uiTools
 
 # torrc parameters that can be defined multiple times without overwriting
 # from src/or/config.c (entries with LINELIST or LINELIST_S)
@@ -92,7 +92,7 @@
     try:
       resetSuccessful = True
       
-      confFile = open(self.confLocation, "r")
+      confFile = open(torTools.getPathPrefix() + self.confLocation, "r")
       self.confContents = confFile.readlines()
       confFile.close()
       

Modified: arm/trunk/src/interface/graphing/bandwidthStats.py
===================================================================
--- arm/trunk/src/interface/graphing/bandwidthStats.py	2010-10-06 15:22:35 UTC (rev 23421)
+++ arm/trunk/src/interface/graphing/bandwidthStats.py	2010-10-06 16:19:49 UTC (rev 23422)
@@ -100,7 +100,7 @@
       return False
     
     # attempt to open the state file
-    try: stateFile = open("%s/state" % dataDir, "r")
+    try: stateFile = open("%s%s/state" % (torTools.getPathPrefix(), dataDir), "r")
     except IOError:
       msg = PREPOPULATE_FAILURE_MSG % "unable to read the state file"
       log.log(self._config["log.graph.bw.prepopulateFailure"], msg)

Modified: arm/trunk/src/interface/logPanel.py
===================================================================
--- arm/trunk/src/interface/logPanel.py	2010-10-06 15:22:35 UTC (rev 23421)
+++ arm/trunk/src/interface/logPanel.py	2010-10-06 16:19:49 UTC (rev 23422)
@@ -199,6 +199,9 @@
   
   if not loggingLocation: return []
   
+  # includes the prefix for tor paths
+  loggingLocation = torTools.getPathPrefix() + loggingLocation
+  
   # if the runlevels argument is a superset of the log file then we can
   # limit the read contents to the addLimit
   loggingTypes = loggingTypes.upper()

Modified: arm/trunk/src/util/torTools.py
===================================================================
--- arm/trunk/src/util/torTools.py	2010-10-06 15:22:35 UTC (rev 23421)
+++ arm/trunk/src/util/torTools.py	2010-10-06 16:19:49 UTC (rev 23422)
@@ -46,9 +46,11 @@
 
 TOR_CTL_CLOSE_MSG = "Tor closed control connection. Exiting event thread."
 UNKNOWN = "UNKNOWN" # value used by cached information if undefined
-CONFIG = {"log.torCtlPortClosed": log.NOTICE,
+CONFIG = {"features.pathPrefix": "",
+          "log.torCtlPortClosed": log.NOTICE,
           "log.torGetInfo": log.DEBUG,
-          "log.torGetConf": log.DEBUG}
+          "log.torGetConf": log.DEBUG,
+          "log.torPrefixPathInvalid": log.NOTICE}
 
 # events used for controller functionality:
 # NOTICE - used to detect when tor is shut down
@@ -63,7 +65,27 @@
 
 def loadConfig(config):
   config.update(CONFIG)
+  
+  # make sure the path prefix is valid and exists (providing a notice if not)
+  prefixPath = CONFIG["features.pathPrefix"].strip()
+  
+  if prefixPath:
+    if prefixPath.endswith("/"): prefixPath = prefixPath[:-1]
+    
+    if prefixPath and not os.path.exists(prefixPath):
+      msg = "The prefix path set in your config (%s) doesn't exist." % prefixPath
+      log.log(CONFIG["log.torPrefixPathInvalid"], msg)
+      prefixPath = ""
+  
+  CONFIG["features.pathPrefix"] = prefixPath
 
+def getPathPrefix():
+  """
+  Provides the path prefix that should be used for fetching tor resources.
+  """
+  
+  return CONFIG["features.pathPrefix"]
+
 def getPid(controlPort=9051, pidFilePath=None):
   """
   Attempts to determine the process id for a running tor process, using the