[ZBX-20604] UserParameterDir defined - crashes all userparameters on Windows Created: 2022 Feb 17  Updated: 2024 Apr 10  Resolved: 2023 May 15

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G), Agent2 plugin (G)
Affects Version/s: 5.4.10, 6.0.12
Fix Version/s: 6.0.18rc1, 6.4.3rc1, 7.0.0alpha1, 7.0 (plan)

Type: Problem report Priority: Minor
Reporter: Igor Gorbach (Inactive) Assignee: Michael Veksler
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows Server 2022


Attachments: File zabbix_agent2-v60-x64.7z     File zabbix_agent2-v60-x64_debug.7z     File zabbix_agent2.exe.7z.001     File zabbix_agent2.exe.7z.002    
Issue Links:
Causes
causes ZBX-22883 Additional fix for ZBX-20604:UserPara... Closed
Team: Team B
Sprint: Sprint 98 (Mar 2023), Sprint 99 (Apr 2023), Sprint 100 (May 2023)
Story Points: 0.25

 Description   

Steps to reproduce:
1. Install Zabbix agent 2 on Windows system
2. Define some user parameters

UserParameter=test,C:\zbx\test.bat # test.bat contains "echo 1"
UserParameter=test1,echo 1

All fine
3. Define UserParameterDir and new UserParameter

UserParameterDir=C:\zbx
UserParameter=test2,.\test.bat

Result:

ZBX_NOTSUPPORTED: Cannot execute command: exec: "C:\\zbx\\cmd.exe": file does not exist

when you trying to run any user parameter
Expected:
All should work fine. No issues on Zabbix Agent (C) 5.4.10



 Comments   
Comment by Aigars Kadikis [ 2022 Dec 27 ]

I can confirm this happens with zabbix_agent2.exe 6.0.12. Problem is there only while running agent as a service (SYSTEM user).

When launching the agent in the foreground under the Administrator account (not SYSTEM), the "UserParameterDir" directive has been picked up properly.

Comment by Michael Veksler [ 2023 Feb 28 ]

Welcome to test zabbix_agent2-v60-x64.7z

Comment by Victor Breda Credidio [ 2023 Feb 28 ]

Hi Michael.

The error now is different, but it still does not work:

ZBX_NOTSUPPORTED: Cannot execute command: fork/exec C:\\Windows\\system32
cmd.exe: The directory name is invalid.

I just replaced the agent executable, added the UserParameterDir to the configuration and restarted the service.

The cmd.exe, though, exists in that path:

dir c:\windows\system32\cmd.exe
 Volume in drive C has no label.
 Volume Serial Number is 4623-3386

 Directory of c:\windows\system32

08/22/2013  11:03 AM           355,840 cmd.exe
               1 File(s)        355,840 bytes
               0 Dir(s)  31,504,572,416 bytes free

Raising the log to “debug” does not give any more info.

Comment by Michael Veksler [ 2023 May 10 ]

Available in:

Comment by Valerii Denysenko [ 2023 May 30 ]

Not fixed after upgrade from 6.4.2 to 6.4.3

Now it returns this:

Cannot find path to cmd.exe command: exec: "cmd.exe": cannot run executable found relative to current directory

Comment by Michael Veksler [ 2023 Jun 01 ]

Hi Antimodest,

Be so kind to test zabbix_agent2.exe.7z.001 & zabbix_agent2.exe.7z.002
with patch:

diff --git a/src/go/pkg/zbxcmd/zbxcmd_windows.go b/src/go/pkg/zbxcmd/zbxcmd_windows.go
index 48d6721994c..2fade9e62e3 100644
--- a/src/go/pkg/zbxcmd/zbxcmd_windows.go
+++ b/src/go/pkg/zbxcmd/zbxcmd_windows.go
@@ -21,6 +21,7 @@ package zbxcmd
 
 import (
 	"bytes"
+	"errors"
 	"fmt"
 	"os/exec"
 	"path/filepath"
@@ -47,7 +48,7 @@ var (
 func execute(s string, timeout time.Duration, path string, strict bool) (out string, err error) {
 	if cmd_path == "" {
 		cmd_exe := "cmd.exe"
-		if cmd_exe, err = exec.LookPath(cmd_exe); err != nil {
+		if cmd_exe, err = exec.LookPath(cmd_exe); err != nil && !errors.Is(err, exec.ErrDot) {
 			return "", fmt.Errorf("Cannot find path to %s command: %s", cmd_exe, err)
 		}
 		if cmd_path, err = filepath.Abs(cmd_exe); err != nil {
@@ -123,7 +124,7 @@ func execute(s string, timeout time.Duration, path string, strict bool) (out str
 func ExecuteBackground(s string) (err error) {
 	if cmd_path == "" {
 		cmd_exe := "cmd.exe"
-		if cmd_exe, err = exec.LookPath(cmd_exe); err != nil {
+		if cmd_exe, err = exec.LookPath(cmd_exe); err != nil && !errors.Is(err, exec.ErrDot) {
 			return fmt.Errorf("Cannot find path to %s command: %s", cmd_exe, err)
 		}
 		if cmd_path, err = filepath.Abs(cmd_exe); err != nil {

Comment by Valerii Denysenko [ 2023 Jun 01 ]

It works now, thanks a lot!

Comment by Michael Veksler [ 2023 Jun 01 ]

Fix MOVED in ZBX-22883

Generated at Fri Apr 04 02:12:50 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.