[tor-commits] [arm/release] fix: appending path prefix to auth cookie path

atagar at torproject.org atagar at torproject.org
Sun Sep 25 21:38:28 UTC 2011


commit 61eca7e9c9ca331e9a6cef082e628df5f6aa78a0
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Sep 8 09:05:51 2011 -0700

    fix: appending path prefix to auth cookie path
    
    Manually declared path prefixes weren't being applied to authentication
    cookies, so chroot instances using cookie auth couldn't connect. Caught by
    sid77
---
 src/starter.py       |    5 +++++
 src/util/torTools.py |    5 ++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/starter.py b/src/starter.py
index a2617f7..6953cf4 100644
--- a/src/starter.py
+++ b/src/starter.py
@@ -225,6 +225,11 @@ def _torCtlConnect(controlAddr="127.0.0.1", controlPort=9051, passphrase=None, i
         try: conn._cookiePath = util.sysTools.expandRelativePath(authValue, torPid)
         except IOError: pass
     
+    # appends the path prefix if it's set
+    if authType == TorCtl.TorCtl.AUTH_TYPE.COOKIE:
+      pathPrefix = util.torTools.getConn().getPathPrefix()
+      authValue = os.path.join(pathPrefix, authValue)
+    
     conn.authenticate(authValue)
     return conn
   except Exception, exc:
diff --git a/src/util/torTools.py b/src/util/torTools.py
index 8567158..c81847c 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -1913,8 +1913,11 @@ class Controller(TorCtl.PostEventListener):
     
     self.connLock.acquire()
     
+    # Checks that the value is unset and we're running. One exception to this
+    # is the pathPrefix which doesn't depend on having a connection and may be
+    # needed for the init.
     currentVal, result = self._cachedParam.get(key), None
-    if currentVal == None and self.isAlive():
+    if currentVal == None and (self.isAlive() or key == "pathPrefix"):
       # still unset - fetch value
       if key in ("nsEntry", "descEntry"):
         myFingerprint = self.getInfo("fingerprint")





More information about the tor-commits mailing list