From 9cc7f7bcf2667060e00af436dee99bf834d868b9 Mon Sep 17 00:00:00 2001 From: mattandes Date: Tue, 4 Dec 2018 18:38:28 -0600 Subject: [PATCH] Fix win_nssm credentials quoting (#48761) * Fix win_nssm credentials quoting Fix credential quoting for win_nssm after changes to the way nssm command is invoked in Ansible 2.7.1. * Updating nssm command to update credentials to use Argv-ToString to properly escape password variable. * Adding changelog fragment for fix of #48728. (cherry picked from commit 15c5dbcc20702b3e7dba8982c846fc08dec51d56) --- changelogs/fragments/48728-win_nssm-credential-quoting.yml | 2 ++ lib/ansible/modules/windows/win_nssm.ps1 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/48728-win_nssm-credential-quoting.yml diff --git a/changelogs/fragments/48728-win_nssm-credential-quoting.yml b/changelogs/fragments/48728-win_nssm-credential-quoting.yml new file mode 100644 index 00000000000..1579ca9afcd --- /dev/null +++ b/changelogs/fragments/48728-win_nssm-credential-quoting.yml @@ -0,0 +1,2 @@ +bugfixes: + - "win_nssm - Switched to Argv-ToString for escaping NSSM credentials (https://github.com/ansible/ansible/issues/48728)" diff --git a/lib/ansible/modules/windows/win_nssm.ps1 b/lib/ansible/modules/windows/win_nssm.ps1 index 0a9cb420a96..323eeb0d712 100644 --- a/lib/ansible/modules/windows/win_nssm.ps1 +++ b/lib/ansible/modules/windows/win_nssm.ps1 @@ -403,7 +403,7 @@ Function Nssm-Update-Credentials } If ($nssm_result.stdout.split("`n`r")[0] -ne $fullUser) { - $cmd = "set ""$name"" ObjectName $fullUser '$password'" + $cmd = Argv-ToString @("set", $name, "ObjectName", $fullUser, $password) $nssm_result = Nssm-Invoke $cmd if ($nssm_result.rc -ne 0)