[util] Remove umask manipulation from makedirs

This causes a race condition: umask is process-wide setting, so any file
created by another thread while the umask is set to 0 will have wrong
permissions. This also removes the possible problem of not resetting the
umask if exception is raised.

Fixes: #239
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-31 09:27:22 +02:00
parent 4ec8ad5de8
commit 69316d827a
2 changed files with 13 additions and 4 deletions

View file

@ -138,13 +138,11 @@ def _doCheckSum(path, hash, logger):
def makedirs(path, mode=0o775):
mask = os.umask(0)
try:
os.makedirs(path, mode=mode)
except OSError as ex:
if ex.errno != errno.EEXIST:
raise
os.umask(mask)
def rmtree(path, ignore_errors=False, onerror=None):