summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-10-24 11:36:41 -0700
committerGitHub <noreply@github.com>2018-10-24 11:36:41 -0700
commita1f90d5b8cd607e54065c285aef97cab17732a7d (patch)
tree4febdf55bf4c0eb8ef4eedc199ce84c0b1b2a598 /lib
parenta0fb2838ea60f020179f480a2db1438da9d2e2ab (diff)
downloadspack-a1f90d5b8cd607e54065c285aef97cab17732a7d.tar.gz
spack-a1f90d5b8cd607e54065c285aef97cab17732a7d.tar.bz2
spack-a1f90d5b8cd607e54065c285aef97cab17732a7d.tar.xz
spack-a1f90d5b8cd607e54065c285aef97cab17732a7d.zip
bugfix: use OS default permissions for mkdirp when mode is not provided (#9604)
- #8773 made the default mode 0o777, which is what's documented but mkdirp actually takes the OS default or umask by default - revert to the Python default by default, and only set the mode when asked explicitly.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/filesystem.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 3a43cfd582..99dfc9a4fd 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -414,13 +414,22 @@ def get_filetype(path_name):
def mkdirp(*paths, **kwargs):
- """Creates a directory, as well as parent directories if needed."""
- mode = kwargs.get('mode', stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
+ """Creates a directory, as well as parent directories if needed.
+
+ Arguments:
+ paths (str): paths to create with mkdirp
+
+ Keyword Aguments:
+ mode (permission bits or None, optional): optional permissions to
+ set on the created directory -- use OS default if not provided
+ """
+ mode = kwargs.get('mode', None)
for path in paths:
if not os.path.exists(path):
try:
- os.makedirs(path, mode)
- os.chmod(path, mode) # For systems that ignore makedirs mode
+ os.makedirs(path)
+ if mode is not None:
+ os.chmod(path, mode)
except OSError as e:
if e.errno != errno.EEXIST or not os.path.isdir(path):
raise e