[tor-commits] [gettor/master] Create directory containing the password file if it doesn't exist already

kaner at torproject.org kaner at torproject.org
Sat Mar 3 11:29:44 UTC 2012


commit 1e89a0ac9163c390e9145f2a01e4b922e7f4237a
Author: Christian Fromme <kaner at strace.org>
Date:   Sat Mar 3 12:29:12 2012 +0100

    Create directory containing the password file if it doesn't exist already
---
 lib/gettor/utils.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/lib/gettor/utils.py b/lib/gettor/utils.py
index 509f90d..ed8a3d7 100644
--- a/lib/gettor/utils.py
+++ b/lib/gettor/utils.py
@@ -209,7 +209,11 @@ def setCmdPassword(conf, password):
     logging.debug("Setting command password")
     passwordHash = str(hashlib.sha1(password).hexdigest())
     # Be nice: Create dir if it's not there
-    passFile = os.path.join(conf.BASEDIR, 'etc', 'gettor', conf.PASSFILE)
+    passwordDir = os.path.join(conf.BASEDIR, 'etc', 'gettor')
+    if not createDir(passwordDir):
+        logging.error("Couldn't create password dir %s" % passwordDir)
+        return False
+    passFile = os.path.join(passwordDir, conf.PASSFILE)
     try:
         fd = open(passFile, 'w')
         fd.write(passwordHash)



More information about the tor-commits mailing list