From eabab560b8b0971d163704a7bbefdd8daf676616 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 7 Jan 2015 13:27:39 -0700 Subject: [PATCH 1/3] Set python_shell=False for ebuild.py --- salt/modules/ebuild.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/salt/modules/ebuild.py b/salt/modules/ebuild.py index f5c2644f2c..29fc333579 100644 --- a/salt/modules/ebuild.py +++ b/salt/modules/ebuild.py @@ -251,7 +251,9 @@ def _get_upgradable(): ''' cmd = 'emerge --pretend --update --newuse --deep --ask n world' - out = __salt__['cmd.run_stdout'](cmd, output_loglevel='trace') + out = __salt__['cmd.run_stdout'](cmd, + output_loglevel='trace', + python_shell=False) rexp = re.compile(r'(?m)^\[.+\] ' r'([^ ]+/[^ ]+)' # Package string @@ -388,16 +390,17 @@ def refresh_db(): # We prefer 'delta-webrsync' to 'webrsync' if salt.utils.which('emerge-delta-webrsync'): cmd = 'emerge-delta-webrsync -q' - return __salt__['cmd.retcode'](cmd) == 0 + return __salt__['cmd.retcode'](cmd, python_shell=False) == 0 else: - if __salt__['cmd.retcode']('emerge --sync --ask n --quiet') == 0: + if __salt__['cmd.retcode']('emerge --sync --ask n --quiet', + python_shell=False) == 0: return True # We fall back to "webrsync" if "rsync" fails for some reason cmd = 'emerge-webrsync -q' # We prefer 'delta-webrsync' to 'webrsync' if salt.utils.which('emerge-delta-webrsync'): cmd = 'emerge-delta-webrsync -q' - return __salt__['cmd.retcode'](cmd) == 0 + return __salt__['cmd.retcode'](cmd, python_shell=False) == 0 def install(name=None, @@ -585,7 +588,9 @@ def install(name=None, cmd = 'emerge --quiet --ask n {0} {1}'.format(emerge_opts, ' '.join(targets)) old = list_pkgs() - call = __salt__['cmd.run_all'](cmd, output_loglevel='trace') + call = __salt__['cmd.run_all'](cmd, + output_loglevel='trace', + python_shell=False) __context__.pop('pkg.list_pkgs', None) if call['retcode'] != 0: return _process_emerge_err(call['stdout'], call['stderr']) @@ -630,7 +635,9 @@ def update(pkg, slot=None, fromrepo=None, refresh=False): old = list_pkgs() cmd = 'emerge --update --newuse --oneshot --ask n --quiet {0}'.format(full_atom) - call = __salt__['cmd.run_all'](cmd, output_loglevel='trace') + call = __salt__['cmd.run_all'](cmd, + output_loglevel='trace', + python_shell=False) __context__.pop('pkg.list_pkgs', None) if call['retcode'] != 0: return _process_emerge_err(call['stdout'], call['stderr']) @@ -658,7 +665,9 @@ def upgrade(refresh=True): old = list_pkgs() cmd = 'emerge --update --newuse --deep --ask n --quiet world' - call = __salt__['cmd.run_all'](cmd, output_loglevel='trace') + call = __salt__['cmd.run_all'](cmd, + output_loglevel='trace', + python_shell=False) __context__.pop('pkg.list_pkgs', None) if call['retcode'] != 0: return _process_emerge_err(call['stdout'], call['stderr']) @@ -718,7 +727,9 @@ def remove(name=None, slot=None, fromrepo=None, pkgs=None, **kwargs): return {} cmd = 'emerge --unmerge --quiet --quiet-unmerge-warn --ask n ' \ '{0}'.format(' '.join(targets)) - __salt__['cmd.run_all'](cmd, output_loglevel='trace') + __salt__['cmd.run_all'](cmd, + output_loglevel='trace', + python_shell=False) __context__.pop('pkg.list_pkgs', None) new = list_pkgs() return salt.utils.compare_dicts(old, new) @@ -807,7 +818,9 @@ def depclean(name=None, slot=None, fromrepo=None, pkgs=None): targets = [x for x in pkg_params if x in old] cmd = 'emerge --depclean --ask n --quiet {0}'.format(' '.join(targets)) - __salt__['cmd.run_all'](cmd, output_loglevel='trace') + __salt__['cmd.run_all'](cmd, + output_loglevel='trace', + python_shell=False) __context__.pop('pkg.list_pkgs', None) new = list_pkgs() return salt.utils.compare_dicts(old, new) From 274e206b9758d7c96b08587317d88957b77228da Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 7 Jan 2015 14:18:53 -0700 Subject: [PATCH 2/3] Set python_shell=False for eselect.py --- salt/modules/eselect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/modules/eselect.py b/salt/modules/eselect.py index 1b2cde189d..4b9afd183c 100644 --- a/salt/modules/eselect.py +++ b/salt/modules/eselect.py @@ -59,8 +59,8 @@ def exec_action(module, action, module_parameter=None, action_parameter=None, pa action_parameter = parameter out = __salt__['cmd.run']( 'eselect --brief --colour=no {0} {1} {2} {3}'.format( - module, module_parameter or '', action, action_parameter or '' - ) + module, module_parameter or '', action, action_parameter or ''), + python_shell=False ) out = out.strip().split('\n') From 788b5209d35e6a350ea2d3652e1568528e7e4170 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Wed, 7 Jan 2015 14:27:51 -0700 Subject: [PATCH 3/3] Set python_shell=False for file.py --- salt/modules/file.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index dc2dd79835..d1fb26c744 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -731,7 +731,7 @@ def sed(path, ) ) - return __salt__['cmd.run_all'](cmd) + return __salt__['cmd.run_all'](cmd, python_shell=False) def sed_contains(path, @@ -771,7 +771,7 @@ def sed_contains(path, flags='p{0}'.format(flags), path=path) - result = __salt__['cmd.run'](cmd) + result = __salt__['cmd.run'](cmd, python_shell=False) return bool(result) @@ -1479,7 +1479,7 @@ def patch(originalfile, patchfile, options='', dry_run=False): dry_run_opt = '' cmd = 'patch {0}{1} "{2}" "{3}"'.format( options, dry_run_opt, originalfile, patchfile) - return __salt__['cmd.run_all'](cmd) + return __salt__['cmd.run_all'](cmd, python_shell=False) def contains(path, text): @@ -2325,7 +2325,7 @@ def restorecon(path, recursive=False): cmd = 'restorecon -FR {0}'.format(path) else: cmd = 'restorecon -F {0}'.format(path) - return not __salt__['cmd.retcode'](cmd) + return not __salt__['cmd.retcode'](cmd, python_shell=False) def get_selinux_context(path): @@ -2338,7 +2338,7 @@ def get_selinux_context(path): salt '*' file.get_selinux_context /etc/hosts ''' - out = __salt__['cmd.run']('ls -Z {0}'.format(path)) + out = __salt__['cmd.run']('ls -Z {0}'.format(path), python_shell=False) try: ret = re.search(r'\w+:\w+:\w+:\w+', out).group(0) @@ -2376,7 +2376,7 @@ def set_selinux_context(path, cmd += '-l {0} '.format(range) cmd += path - ret = not __salt__['cmd.retcode'](cmd) + ret = not __salt__['cmd.retcode'](cmd, python_shell=False) if ret: return get_selinux_context(path) else: @@ -3957,7 +3957,7 @@ def grep(path, ) try: - ret = __salt__['cmd.run_all'](cmd) + ret = __salt__['cmd.run_all'](cmd, python_shell=False) except (IOError, OSError) as exc: raise CommandExecutionError(exc.strerror)