Skip to content

Commit

Permalink
sweep: #6395 Use safer mode for grid-security directories
Browse files Browse the repository at this point in the history
  • Loading branch information
sfayer authored and web-flow committed Oct 3, 2022
1 parent f67f58e commit ccb3489
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/DIRAC/Core/Utilities/File.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@
}


def mkDir(path):
"""Emulate 'mkdir -p path' (if path exists already, don't raise an exception)"""
def mkDir(path, mode=None):
"""Emulate 'mkdir -p path' (if path exists already, don't raise an exception)
:param str path: directory hierarchy to create
:param int mode: Use this mode as the mode for new directories, use python default if None.
"""
try:
if os.path.isdir(path):
return
os.makedirs(path)
if mode is None:
os.makedirs(path)
else:
os.makedirs(path, mode)
except OSError as osError:
if osError.errno == errno.EEXIST and os.path.isdir(path):
pass
Expand Down
4 changes: 2 additions & 2 deletions src/DIRAC/Core/scripts/dirac_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def runDiracConfigure(params):
Script.enableCS()
try:
dirName = os.path.join(DIRAC.rootPath, "etc", "grid-security", "certificates")
mkDir(dirName)
mkDir(dirName, 0o755)
except Exception:
DIRAC.gLogger.exception()
DIRAC.gLogger.fatal("Fail to create directory:", dirName)
Expand Down Expand Up @@ -640,7 +640,7 @@ def runDiracConfigure(params):
vomsDirPath = os.path.join(DIRAC.rootPath, "etc", "grid-security", "vomsdir", voName)
vomsesDirPath = os.path.join(DIRAC.rootPath, "etc", "grid-security", "vomses")
for path in (vomsDirPath, vomsesDirPath):
mkDir(path)
mkDir(path, 0o755)
vomsesLines = []
for vomsHost in vomsDict[vo].get("Servers", {}):
hostFilePath = os.path.join(vomsDirPath, "%s.lsc" % vomsHost)
Expand Down

0 comments on commit ccb3489

Please sign in to comment.