From 118608999c0301983d9a5fc001e65bd252e9e7d3 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 23 Mar 2022 22:55:10 +0000 Subject: [PATCH] strip windows newlines on nix --- agent/agent_linux.go | 1 + agent/utils.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/agent/agent_linux.go b/agent/agent_linux.go index 473eb71..0b0434a 100644 --- a/agent/agent_linux.go +++ b/agent/agent_linux.go @@ -133,6 +133,7 @@ func NewAgentConfig() *rmm.AgentConfig { } func (a *Agent) RunScript(code string, shell string, args []string, timeout int) (stdout, stderr string, exitcode int, e error) { + code = removeWinNewLines(code) content := []byte(code) f, err := os.CreateTemp("", "trmm") diff --git a/agent/utils.go b/agent/utils.go index 80a7f90..e4baebc 100644 --- a/agent/utils.go +++ b/agent/utils.go @@ -298,3 +298,7 @@ func randRange(min, max int) int { func randomCheckDelay() { time.Sleep(time.Duration(randRange(300, 950)) * time.Millisecond) } + +func removeWinNewLines(s string) string { + return strings.ReplaceAll(s, "\r\n", "\n") +}