mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Migrate away from pipes.quote (#56785)
* Migrate away from pipes.quote * Fix sanity
This commit is contained in:
committed by
Brian Coca
parent
86354ff1fb
commit
3b9478ade0
@@ -207,13 +207,13 @@ EXAMPLES = r'''
|
||||
|
||||
import os
|
||||
import platform
|
||||
import pipes
|
||||
import pwd
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, get_platform
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
|
||||
|
||||
CRONCMD = "/usr/bin/crontab"
|
||||
@@ -514,13 +514,13 @@ class CronTab(object):
|
||||
user = ''
|
||||
if self.user:
|
||||
if platform.system() == 'SunOS':
|
||||
return "su %s -c '%s -l'" % (pipes.quote(self.user), pipes.quote(CRONCMD))
|
||||
return "su %s -c '%s -l'" % (shlex_quote(self.user), shlex_quote(CRONCMD))
|
||||
elif platform.system() == 'AIX':
|
||||
return "%s -l %s" % (pipes.quote(CRONCMD), pipes.quote(self.user))
|
||||
return "%s -l %s" % (shlex_quote(CRONCMD), shlex_quote(self.user))
|
||||
elif platform.system() == 'HP-UX':
|
||||
return "%s %s %s" % (CRONCMD, '-l', pipes.quote(self.user))
|
||||
return "%s %s %s" % (CRONCMD, '-l', shlex_quote(self.user))
|
||||
elif pwd.getpwuid(os.getuid())[0] != self.user:
|
||||
user = '-u %s' % pipes.quote(self.user)
|
||||
user = '-u %s' % shlex_quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, '-l')
|
||||
|
||||
def _write_execute(self, path):
|
||||
@@ -530,10 +530,10 @@ class CronTab(object):
|
||||
user = ''
|
||||
if self.user:
|
||||
if platform.system() in ['SunOS', 'HP-UX', 'AIX']:
|
||||
return "chown %s %s ; su '%s' -c '%s %s'" % (pipes.quote(self.user), pipes.quote(path), pipes.quote(self.user), CRONCMD, pipes.quote(path))
|
||||
return "chown %s %s ; su '%s' -c '%s %s'" % (shlex_quote(self.user), shlex_quote(path), shlex_quote(self.user), CRONCMD, shlex_quote(path))
|
||||
elif pwd.getpwuid(os.getuid())[0] != self.user:
|
||||
user = '-u %s' % pipes.quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, pipes.quote(path))
|
||||
user = '-u %s' % shlex_quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, shlex_quote(path))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -98,7 +98,6 @@ EXAMPLES = r'''
|
||||
'''
|
||||
|
||||
import os
|
||||
import pipes
|
||||
import platform
|
||||
import pwd
|
||||
import re
|
||||
@@ -107,6 +106,7 @@ import sys
|
||||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
|
||||
CRONCMD = "/usr/bin/crontab"
|
||||
|
||||
@@ -296,13 +296,13 @@ class CronVar(object):
|
||||
|
||||
if self.user:
|
||||
if platform.system() == 'SunOS':
|
||||
return "su %s -c '%s -l'" % (pipes.quote(self.user), pipes.quote(CRONCMD))
|
||||
return "su %s -c '%s -l'" % (shlex_quote(self.user), shlex_quote(CRONCMD))
|
||||
elif platform.system() == 'AIX':
|
||||
return "%s -l %s" % (pipes.quote(CRONCMD), pipes.quote(self.user))
|
||||
return "%s -l %s" % (shlex_quote(CRONCMD), shlex_quote(self.user))
|
||||
elif platform.system() == 'HP-UX':
|
||||
return "%s %s %s" % (CRONCMD, '-l', pipes.quote(self.user))
|
||||
return "%s %s %s" % (CRONCMD, '-l', shlex_quote(self.user))
|
||||
elif pwd.getpwuid(os.getuid())[0] != self.user:
|
||||
user = '-u %s' % pipes.quote(self.user)
|
||||
user = '-u %s' % shlex_quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, '-l')
|
||||
|
||||
def _write_execute(self, path):
|
||||
@@ -312,10 +312,10 @@ class CronVar(object):
|
||||
user = ''
|
||||
if self.user:
|
||||
if platform.system() in ['SunOS', 'HP-UX', 'AIX']:
|
||||
return "chown %s %s ; su '%s' -c '%s %s'" % (pipes.quote(self.user), pipes.quote(path), pipes.quote(self.user), CRONCMD, pipes.quote(path))
|
||||
return "chown %s %s ; su '%s' -c '%s %s'" % (shlex_quote(self.user), shlex_quote(path), shlex_quote(self.user), CRONCMD, shlex_quote(path))
|
||||
elif pwd.getpwuid(os.getuid())[0] != self.user:
|
||||
user = '-u %s' % pipes.quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, pipes.quote(path))
|
||||
user = '-u %s' % shlex_quote(self.user)
|
||||
return "%s %s %s" % (CRONCMD, user, shlex_quote(path))
|
||||
|
||||
|
||||
# ==================================================
|
||||
|
||||
@@ -142,10 +142,10 @@ EXAMPLES = r'''
|
||||
|
||||
import json
|
||||
import os
|
||||
import pipes
|
||||
import stat
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
|
||||
|
||||
def _get_facter_dir():
|
||||
@@ -239,7 +239,7 @@ def main():
|
||||
if TIMEOUT_CMD:
|
||||
base_cmd = "%(timeout_cmd)s -s 9 %(timeout)s %(puppet_cmd)s" % dict(
|
||||
timeout_cmd=TIMEOUT_CMD,
|
||||
timeout=pipes.quote(p['timeout']),
|
||||
timeout=shlex_quote(p['timeout']),
|
||||
puppet_cmd=PUPPET_CMD)
|
||||
else:
|
||||
base_cmd = PUPPET_CMD
|
||||
@@ -249,7 +249,7 @@ def main():
|
||||
" --no-daemonize --no-usecacheonfailure --no-splay"
|
||||
" --detailed-exitcodes --verbose --color 0") % dict(base_cmd=base_cmd)
|
||||
if p['puppetmaster']:
|
||||
cmd += " --server %s" % pipes.quote(p['puppetmaster'])
|
||||
cmd += " --server %s" % shlex_quote(p['puppetmaster'])
|
||||
if p['show_diff']:
|
||||
cmd += " --show_diff"
|
||||
if p['environment']:
|
||||
@@ -289,7 +289,7 @@ def main():
|
||||
if p['execute']:
|
||||
cmd += " --execute '%s'" % p['execute']
|
||||
else:
|
||||
cmd += pipes.quote(p['manifest'])
|
||||
cmd += shlex_quote(p['manifest'])
|
||||
if p['summarize']:
|
||||
cmd += " --summarize"
|
||||
if p['debug']:
|
||||
|
||||
@@ -86,10 +86,10 @@ RETURN = '''
|
||||
...
|
||||
'''
|
||||
|
||||
import pipes
|
||||
import sys
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
|
||||
|
||||
class XfconfPreference(object):
|
||||
@@ -107,12 +107,12 @@ class XfconfPreference(object):
|
||||
|
||||
# Execute the call
|
||||
cmd = "{0} --channel {1} --property {2}".format(self.module.get_bin_path('xfconf-query', True),
|
||||
pipes.quote(self.channel),
|
||||
pipes.quote(self.property))
|
||||
shlex_quote(self.channel),
|
||||
shlex_quote(self.property))
|
||||
try:
|
||||
if call_type == 'set':
|
||||
cmd += " --type {0} --create --set {1}".format(pipes.quote(self.value_type),
|
||||
pipes.quote(self.value))
|
||||
cmd += " --type {0} --create --set {1}".format(shlex_quote(self.value_type),
|
||||
shlex_quote(self.value))
|
||||
elif call_type == 'unset':
|
||||
cmd += " --reset"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user