Merge pull request #1353 from mscherer/remove_unsafe_shell_pkgutil

Simplify the code and remove use_unsafe_shell=True
reviewable/pr18780/r1
Brian Coca 9 years ago
commit a412ee7ed8

@ -76,14 +76,13 @@ def package_latest(module, name, site):
# Only supports one package # Only supports one package
cmd = [ 'pkgutil', '--single', '-c' ] cmd = [ 'pkgutil', '--single', '-c' ]
if site is not None: if site is not None:
cmd += [ '-t', pipes.quote(site) ] cmd += [ '-t', site]
cmd.append(pipes.quote(name)) cmd.append(name)
cmd += [ '| tail -1 | grep -v SAME' ] rc, out, err = run_command(module, cmd)
rc, out, err = run_command(module, cmd, use_unsafe_shell=True) # replace | tail -1 |grep -v SAME
if rc == 1: # use -2, because splitting on \n create a empty line
return True # at the end of the list
else: return 'SAME' in out.split('\n')[-2]
return False
def run_command(module, cmd, **kwargs): def run_command(module, cmd, **kwargs):
progname = cmd[0] progname = cmd[0]

Loading…
Cancel
Save