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

[tor-commits] [chutney/master] Another python3 fix, about directory permissions made by os.makedirs



commit 49087abb2aba3c8acafd16287cc158f55d5ca6de
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Feb 28 12:52:56 2019 -0500

    Another python3 fix, about directory permissions made by os.makedirs
    
    In python3, os.makedir()'s mode argument doesn't affect any
    directory created except the last one in the path.
---
 lib/chutney/TorNet.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 82d50cf..ddcdc87 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -45,6 +45,10 @@ def mkdir_p(d, mode=448):
        448 is the decimal representation of the octal number 0700. Since
        python2 only supports 0700 and python3 only supports 0o700, we can use
        neither.
+
+       Note that python2 and python3 differ in how they create the
+       permissions for the intermediate directories.  In python3, 'mode'
+       only sets the mode for the last directory created.
     """
     try:
         os.makedirs(d, mode=mode)
@@ -485,6 +489,8 @@ class LocalNodeBuilder(NodeBuilder):
         """Create the data directory (with keys subdirectory) for this node.
         """
         datadir = self._env['dir']
+        # We do this separately to make sure the permissions are correct.
+        mkdir_p(datadir)
         mkdir_p(os.path.join(datadir, 'keys'))
 
     def _makeHiddenServiceDir(self):
@@ -495,6 +501,8 @@ class LocalNodeBuilder(NodeBuilder):
           path to the hidden service directory.
         """
         datadir = self._env['dir']
+        # We do this separately to make sure the permissions are correct.
+        mkdir_p(datadir)
         mkdir_p(os.path.join(datadir, self._env['hs_directory']))
 
     def _genAuthorityKey(self):



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