Allow setting the cmd_umask from within the roster

This commit is contained in:
Colton Myers 2015-12-10 14:49:42 -07:00
parent 08dd663a27
commit 5c03f892bc
2 changed files with 8 additions and 1 deletions

View file

@ -611,6 +611,7 @@ class Single(object):
# Get mine setting and mine_functions if defined in kwargs (from roster)
self.mine = mine
self.mine_functions = kwargs.get('mine_functions')
self.cmd_umask = kwargs.get('cmd_umask', None)
self.opts = opts
self.tty = tty
@ -909,7 +910,8 @@ OPTIONS.version = '{5}'
OPTIONS.ext_mods = '{6}'
OPTIONS.wipe = {7}
OPTIONS.tty = {8}
ARGS = {9}\n'''.format(self.minion_config,
OPTIONS.cmd_umask = {9}
ARGS = {10}\n'''.format(self.minion_config,
RSTR,
self.thin_dir,
thin_sum,
@ -918,6 +920,7 @@ ARGS = {9}\n'''.format(self.minion_config,
self.mods.get('version', ''),
self.wipe,
self.tty,
self.cmd_umask,
self.argv)
py_code = SSH_PY_SHIM.replace('#%%OPTS', arg_str)
py_code_enc = py_code.encode('base64')

View file

@ -216,6 +216,8 @@ def main(argv): # pylint: disable=W0613
sys.stdout.flush()
sys.stderr.write(OPTIONS.delimiter + '\n')
sys.stderr.flush()
if OPTIONS.cmd_umask is not None:
old_umask = os.umask(OPTIONS.cmd_umask)
if OPTIONS.tty:
stdout, _ = subprocess.Popen(salt_argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
sys.stdout.write(stdout)
@ -227,6 +229,8 @@ def main(argv): # pylint: disable=W0613
shutil.rmtree(OPTIONS.saltdir)
else:
os.execv(sys.executable, salt_argv)
if OPTIONS.cmd_umask is not None:
os.umask(old_umask)
if __name__ == '__main__':
sys.exit(main(sys.argv))