Skip to content

Commit 11abda8

Browse files
committed
fix: update remote system detection command for Windows compatibility
The current Windows system detection uses a simple `ver` command which fails on Windows servers where PowerShell is configured as the default SSH shell. The `ver` command is only available in CMD, not in PowerShell, causing system detection to fail incorrectly.
1 parent 4583290 commit 11abda8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (p *Plugin) removeAllDestFile() error {
147147
},
148148
}
149149

150-
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
150+
_, _, _, err := ssh.Run("cmd /c ver 2>$null", p.Config.CommandTimeout)
151151
systemType := "unix"
152152
if err == nil {
153153
systemType = "windows"
@@ -292,7 +292,7 @@ func (p *Plugin) Exec() error {
292292
}
293293

294294
systemType := "unix"
295-
_, _, _, err := ssh.Run("ver", p.Config.CommandTimeout)
295+
_, _, _, err := ssh.Run("cmd /c ver 2>$null", p.Config.CommandTimeout)
296296
if err == nil {
297297
systemType = "windows"
298298
}

plugin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func TestRemoveDestFile(t *testing.T) {
571571
DestFile: "/etc/resolv.conf",
572572
}
573573

574-
_, _, _, err := ssh.Run("ver", plugin.Config.CommandTimeout)
574+
_, _, _, err := ssh.Run("cmd /c ver 2>$null", plugin.Config.CommandTimeout)
575575
systemType := "unix"
576576
if err == nil {
577577
systemType = "windows"

0 commit comments

Comments
 (0)