mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #29609 from basepi/salt-ssh.umask.29574
[2015.8][salt-ssh] Add ability to set salt-ssh command umask in roster
This commit is contained in:
commit
41b8117237
3 changed files with 10 additions and 1 deletions
|
@ -51,6 +51,8 @@ The information which can be stored in a roster ``target`` is the following:
|
|||
minion_opts: # Dictionary of minion opts
|
||||
thin_dir: # The target system's storage directory for Salt
|
||||
# components. Defaults to /tmp/salt-<hash>.
|
||||
cmd_umask: # umask to enforce for the salt-call command. Should be in
|
||||
# octal (so for 0o077 in YAML you would do 0077, or 63)
|
||||
|
||||
thin_dir
|
||||
--------
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue