rundeck-plugins / py-winrm-plugin

15 stars 21 forks source link

PyWinRM fails when using options as Windows paths due to quotes #68

Closed nvalenzuela20 closed 3 years ago

nvalenzuela20 commented 3 years ago

Environment: Rundeck Enterprise 3.3.6 PyWinRM 2.0.10 - CMD interpreter (Powershell not allowed) Not happening on JSCH for linux nodes.

When using options with Windows paths that uses backslashes, i.e: C:\test\${option.script} Rundeck does escape those backslashes by adding single quotes to it. When this is added and then passed to Windows CMD, i.e to list the fullpath: dir C:\test\${option.script} the command fails due to single quotes

Within the PyWinRm plugin code there is this line that retrieves the command from env variable, which is the failing one: exec_command = os.getenv("RD_EXEC_COMMAND")

When this variable is replaced with nothing or double quotes, the command runs successfully: exec_command = exec_command.replace("'", """)

Although this workaround can retrieve unexpected outputs (if single quotes are explicitly needed on output) from more complex job workflows.

nvalenzuela20 commented 3 years ago

Tested by @dlvcrk