[tor-commits] [arm/release] Accounting for os.path.join being stupid

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


commit 45b47166af00edc4e59c46548c2e52672042b9e3
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Sep 12 08:27:01 2011 -0700

    Accounting for os.path.join being stupid
    
    The os.path.join function simply doesn't work if the second argument is an
    absolute path. That is stupid. Working around this by making its second
    argument relative.
---
 src/starter.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/starter.py b/src/starter.py
index 6953cf4..e4e7096 100644
--- a/src/starter.py
+++ b/src/starter.py
@@ -228,7 +228,15 @@ def _torCtlConnect(controlAddr="127.0.0.1", controlPort=9051, passphrase=None, i
     # 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)
+      
+      # The os.path.join function is kinda stupid. If given an absolute path
+      # with the second argument then it will swallow the prefix. Ie...
+      # os.path.join("/tmp", "/foo") => "/foo"
+      
+      pathSuffix = conn._cookiePath
+      if pathSuffix.startswith("/"): pathSuffix = pathSuffix[1:]
+      
+      conn._cookiePath = os.path.join(pathPrefix, pathSuffix)
     
     conn.authenticate(authValue)
     return conn





More information about the tor-commits mailing list