Merge pull request #29126 from fcrozat/2015.8

Fix deployment when umask is non-standard
This commit is contained in:
Mike Place 2015-11-23 10:53:46 -07:00
commit dc0d47fa2e

View File

@ -92,8 +92,10 @@ def get_hash(path, form='sha1', chunk_size=4096):
def unpack_thin(thin_path): def unpack_thin(thin_path):
"""Unpack the Salt thin archive.""" """Unpack the Salt thin archive."""
tfile = tarfile.TarFile.gzopen(thin_path) tfile = tarfile.TarFile.gzopen(thin_path)
old_umask = os.umask(0o077)
tfile.extractall(path=OPTIONS.saltdir) tfile.extractall(path=OPTIONS.saltdir)
tfile.close() tfile.close()
os.umask(old_umask)
os.unlink(thin_path) os.unlink(thin_path)
@ -114,8 +116,10 @@ def unpack_ext(ext_path):
'minion', 'minion',
'extmods') 'extmods')
tfile = tarfile.TarFile.gzopen(ext_path) tfile = tarfile.TarFile.gzopen(ext_path)
old_umask = os.umask(0o077)
tfile.extractall(path=modcache) tfile.extractall(path=modcache)
tfile.close() tfile.close()
os.umask(old_umask)
os.unlink(ext_path) os.unlink(ext_path)
ver_path = os.path.join(modcache, 'ext_version') ver_path = os.path.join(modcache, 'ext_version')
ver_dst = os.path.join(OPTIONS.saltdir, 'ext_version') ver_dst = os.path.join(OPTIONS.saltdir, 'ext_version')
@ -212,6 +216,7 @@ def main(argv): # pylint: disable=W0613
sys.stdout.flush() sys.stdout.flush()
sys.stderr.write(OPTIONS.delimiter + '\n') sys.stderr.write(OPTIONS.delimiter + '\n')
sys.stderr.flush() sys.stderr.flush()
old_umask = os.umask(0o077)
if OPTIONS.tty: if OPTIONS.tty:
stdout, _ = subprocess.Popen(salt_argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() stdout, _ = subprocess.Popen(salt_argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
sys.stdout.write(stdout) sys.stdout.write(stdout)
@ -223,6 +228,7 @@ def main(argv): # pylint: disable=W0613
shutil.rmtree(OPTIONS.saltdir) shutil.rmtree(OPTIONS.saltdir)
else: else:
os.execv(sys.executable, salt_argv) os.execv(sys.executable, salt_argv)
os.umask(old_umask)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))