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

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



commit 45b47166af00edc4e59c46548c2e52672042b9e3
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
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

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits