diff --git a/packaging/pkgin b/packaging/pkgin index 0554cf9a216..866c9f76a4c 100755 --- a/packaging/pkgin +++ b/packaging/pkgin @@ -58,13 +58,13 @@ import json import shlex import os import sys - +import pipes def query_package(module, pkgin_path, name, state="present"): if state == "present": - rc, out, err = module.run_command("%s -y list | grep ^%s" % (pkgin_path, name)) + rc, out, err = module.run_command("%s -y list | grep ^%s" % (pipes.quote(pkgin_path), pipes.quote(name)), use_unsafe_shell=True) if rc == 0: # At least one package with a package name that starts with ``name`` diff --git a/packaging/pkgutil b/packaging/pkgutil index d6c4f536c5a..e7d1ce7a0d6 100644 --- a/packaging/pkgutil +++ b/packaging/pkgutil @@ -58,13 +58,14 @@ pkgutil: name=CSWcommon state=present # Install a package from a specific repository pkgutil: name=CSWnrpe site='ftp://myinternal.repo/opencsw/kiel state=latest' ''' + import os +import pipes def package_installed(module, name): cmd = [module.get_bin_path('pkginfo', True)] cmd.append('-q') cmd.append(name) - #rc, out, err = module.run_command(' '.join(cmd), shell=False) rc, out, err = module.run_command(' '.join(cmd)) if rc == 0: return True @@ -73,12 +74,14 @@ def package_installed(module, name): def package_latest(module, name, site): # Only supports one package + name = pipes.quote(name) + site = pipes.quote(site) cmd = [ 'pkgutil', '--single', '-c' ] if site is not None: cmd += [ '-t', site ] cmd.append(name) cmd += [ '| tail -1 | grep -v SAME' ] - rc, out, err = module.run_command(' '.join(cmd)) + rc, out, err = module.run_command(' '.join(cmd), use_unsafe_shell=True) if rc == 1: return True else: diff --git a/packaging/redhat_subscription b/packaging/redhat_subscription index bb5d655a52f..0e5ce0856d2 100644 --- a/packaging/redhat_subscription +++ b/packaging/redhat_subscription @@ -216,7 +216,6 @@ class Rhsm(RegistrationBase): if password: args.extend(['--password', password]) - # Do the needful... rc, stderr, stdout = self.module.run_command(args, check_rc=True) def unsubscribe(self): diff --git a/packaging/swdepot b/packaging/swdepot index 6fd89088cc0..b41a860531f 100644 --- a/packaging/swdepot +++ b/packaging/swdepot @@ -19,6 +19,7 @@ # along with this software. If not, see . import re +import pipes DOCUMENTATION = ''' --- @@ -78,9 +79,9 @@ def query_package(module, name, depot=None): cmd_list = '/usr/sbin/swlist -a revision -l product' if depot: - rc, stdout, stderr = module.run_command("%s -s %s %s | grep %s" % (cmd_list, depot, name, name)) + rc, stdout, stderr = module.run_command("%s -s %s %s | grep %s" % (cmd_list, pipes.quote(depot), pipes.quote(name), pipes.quote(name)), use_unsafe_shell=True) else: - rc, stdout, stderr = module.run_command("%s %s | grep %s" % (cmd_list, name, name)) + rc, stdout, stderr = module.run_command("%s %s | grep %s" % (cmd_list, pipes.quote(name), pipes.quote(name)), use_unsafe_shell=True) if rc == 0: version = re.sub("\s\s+|\t" , " ", stdout).strip().split()[1] else: diff --git a/packaging/urpmi b/packaging/urpmi index 72dfef02011..be49dfd2648 100644 --- a/packaging/urpmi +++ b/packaging/urpmi @@ -104,7 +104,7 @@ def query_package_provides(module, name): # rpm -q returns 0 if the package is installed, # 1 if it is not installed - cmd = "rpm -q --provides %s >/dev/null" % (name) + cmd = "rpm -q --provides %s" % (name) rc, stdout, stderr = module.run_command(cmd, check_rc=False) return rc == 0 @@ -125,7 +125,7 @@ def remove_packages(module, packages): if not query_package(module, package): continue - cmd = "%s --auto %s > /dev/null" % (URPME_PATH, package) + cmd = "%s --auto %s" % (URPME_PATH, package) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: @@ -158,7 +158,7 @@ def install_packages(module, pkgspec, force=True, no_suggests=True): else: force_yes = '' - cmd = ("%s --auto %s --quiet %s %s > /dev/null" % (URPMI_PATH, force_yes, no_suggests_yes, packages)) + cmd = ("%s --auto %s --quiet %s %s" % (URPMI_PATH, force_yes, no_suggests_yes, packages)) rc, out, err = module.run_command(cmd)