-
Problem report
-
Resolution: Fixed
-
Trivial
-
6.0.29, 6.4.14
-
None
-
Prev.Sprint, S24-W34/35
-
0.3
Example of commands used:
Alias=update.zabbix.agent[fg]:system.run["\"C:\Program Files\Zabbix Agent\python\python.exe\" \"C:\Program Files\Zabbix Agent\bin\update-zabbix_agent.py\" --workhours-only --no-proxy",wait] Alias=update.zabbix.agent[bg]:system.run["\"C:\Program Files\Zabbix Agent\python\python.exe\" \"C:\Program Files\Zabbix Agent\bin\update-zabbix_agent.py\" --workhours-only --no-proxy",nowait]
Python scripts logs the command line used when called, and I noticed that when the agent is requested "update.zabbix.agent[fg]" the log reports the correct parameters, but when "update.zabbix.agent[bg]" is requested, the two parameters following the script are lost.
The agent debug log did not report anything unusual, and the commands were both reported complete when run.
Looking at the agent source codeĀ (src/go/pkg/zbxcmd/zbxcmd_windows.go):
When called with "wait", the entire command is passed to CMD.EXE with additional double-quotes that are NOT present when the same command is executed via "nowait".
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/src/go/pkg/zbxcmd/zbxcmd_windows.go#67,130
If I manually insert those additional quotes, the command works as expected:
Alias=update.zabbix.agent[bg]:system.run["\"\"C:\Program Files\Zabbix Agent\python\python.exe\" \"C:\Program Files\Zabbix Agent\bin\update-zabbix_agent.py\" --workhours-only --no-proxy\"",nowait]
This patch should solve the problem:
diff --git a/src/go/pkg/zbxcmd/zbxcmd_windows.go b/src/go/pkg/zbxcmd/zbxcmd_windows.go index 7741e412f5d..cf65385a1f5 100644 --- a/src/go/pkg/zbxcmd/zbxcmd_windows.go +++ b/src/go/pkg/zbxcmd/zbxcmd_windows.go @@ -133,7 +133,7 @@ func ExecuteBackground(s string) (err error) { } cmd := exec.Command(cmd_path) cmd.SysProcAttr = &windows.SysProcAttr{ - CmdLine: fmt.Sprintf(`/C %s`, s), + CmdLine: fmt.Sprintf(`/C "%s"`, s), } if err = cmd.Start(); err != nil {