[tor-commits] [chutney/master] Change the default mode when creating directories

teor at torproject.org teor at torproject.org
Mon Feb 27 02:23:17 UTC 2017


commit 501dff31d2b0ac60087e4559fa137bc5578cd853
Author: cypherpunks <cypherpunks at torproject.org>
Date:   Fri Feb 24 10:13:52 2017 +0000

    Change the default mode when creating directories
    
    Every call to `mkdir_p` uses mode 448 which is a sensible default. Using
    this mode as the global default prevents future problems, removes
    duplicate comments and simplifies existing calls.
    
    Closes #21552.
---
 lib/chutney/TorNet.py | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index ced5727..c9668f8 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -32,12 +32,12 @@ _THE_NETWORK = None
 cgitb.enable(format="plain")
 
 
-def mkdir_p(d, mode=511):
+def mkdir_p(d, mode=448):
     """Create directory 'd' and all of its parents as needed.  Unlike
        os.makedirs, does not give an error if d already exists.
 
-       511 is the decimal representation of the octal number 0777. Since
-       python2 only supports 0777 and python3 only supports 0o777, we can use
+       448 is the decimal representation of the octal number 0700. Since
+       python2 only supports 0700 and python3 only supports 0o700, we can use
        neither.
     """
     try:
@@ -335,13 +335,9 @@ class LocalNodeBuilder(NodeBuilder):
 
     def _makeDataDir(self):
         """Create the data directory (with keys subdirectory) for this node.
-
-          448 is the decimal representation of the octal number 0700. Since
-          python2 only supports 0700 and python3 only supports 0o700, we can
-          use neither.
         """
         datadir = self._env['dir']
-        mkdir_p(os.path.join(datadir, 'keys'), 448)
+        mkdir_p(os.path.join(datadir, 'keys'))
 
     def _makeHiddenServiceDir(self):
         """Create the hidden service subdirectory for this node.
@@ -349,13 +345,9 @@ class LocalNodeBuilder(NodeBuilder):
           The directory name is stored under the 'hs_directory' environment
           key. It is combined with the 'dir' data directory key to yield the
           path to the hidden service directory.
-
-          448 is the decimal representation of the octal number 0700. Since
-          python2 only supports 0700 and python3 only supports 0o700, we can
-          use neither.
         """
         datadir = self._env['dir']
-        mkdir_p(os.path.join(datadir, self._env['hs_directory']), 448)
+        mkdir_p(os.path.join(datadir, self._env['hs_directory']))
 
     def _genAuthorityKey(self):
         """Generate an authority identity and signing key for this authority,



More information about the tor-commits mailing list