Prevent failed os.makedirs from leaving modified umask in place

This commit is contained in:
Erik Johnson 2018-02-26 19:51:29 -06:00
parent 633e1208e4
commit 82ce546e18
No known key found for this signature in database
GPG Key ID: 5E5583C437808F3F

View File

@ -106,8 +106,10 @@ def need_deployment():
if os.path.exists(OPTIONS.saltdir):
shutil.rmtree(OPTIONS.saltdir)
old_umask = os.umask(0o077)
os.makedirs(OPTIONS.saltdir)
os.umask(old_umask)
try:
os.makedirs(OPTIONS.saltdir)
finally:
os.umask(old_umask)
# Verify perms on saltdir
if not is_windows():
euid = os.geteuid()