From 7ace25dd6d530d543c5ff8a818efee28905cfccd Mon Sep 17 00:00:00 2001 From: Allen Smith Date: Tue, 11 Feb 2020 06:20:14 +0800 Subject: [PATCH] Backport of pmrun.py: Recreate the older behavior where the entire success command was quoted (#67241) * pmrun - quote success command (#66929) * Recreate the older behavior where the entire success command was quoted * Use shlex_quote for a correct fix of this * Add changelog fragment (cherry picked from commit fd8eb77cc3febf0a310bf42abe60d75dc23d9f79) * Backport of 66929-pmrun-quote-entire-success-command-string * Update changelog fragment * Delete 66929-pmrun-quote-entire-success-command-string.yml Unclear from docs, but this is the devel fragment so removing. * Update changelog --- .../67241-pmrun-quote-entire-success-command-string.yml | 2 ++ lib/ansible/plugins/become/pmrun.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/67241-pmrun-quote-entire-success-command-string.yml diff --git a/changelogs/fragments/67241-pmrun-quote-entire-success-command-string.yml b/changelogs/fragments/67241-pmrun-quote-entire-success-command-string.yml new file mode 100644 index 00000000000..82198c5f7a6 --- /dev/null +++ b/changelogs/fragments/67241-pmrun-quote-entire-success-command-string.yml @@ -0,0 +1,2 @@ +bugfixes: + - pmrun plugin - The success command string was no longer quoted. This caused unusual use-cases like ``become_flags=su - root -c`` to fail. diff --git a/lib/ansible/plugins/become/pmrun.py b/lib/ansible/plugins/become/pmrun.py index 023cf408ba3..070352493d6 100644 --- a/lib/ansible/plugins/become/pmrun.py +++ b/lib/ansible/plugins/become/pmrun.py @@ -57,6 +57,7 @@ DOCUMENTATION = """ """ from ansible.plugins.become import BecomeBase +from ansible.module_utils.six.moves import shlex_quote class BecomeModule(BecomeBase): @@ -72,4 +73,4 @@ class BecomeModule(BecomeBase): become = self.get_option('become_exe') or self.name flags = self.get_option('become_flags') or '' - return '%s %s %s' % (become, flags, self._build_success_command(cmd, shell)) + return '%s %s %s' % (become, flags, shlex_quote(self._build_success_command(cmd, shell)))