From 934700844c4a28c35bb73cb1cdbbab4bc1725387 Mon Sep 17 00:00:00 2001 From: redanthrax Date: Fri, 17 Jun 2022 10:16:36 -0700 Subject: [PATCH] fixed windows build - removed test dep --- README.md | 7 ++++++- agent/agent_windows.go | 9 --------- agent/install.go | 6 ------ agent/install_linux.go | 3 --- agent/install_windows.go | 10 ---------- 5 files changed, 6 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index aaaeaf6..77b0e2c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ ### Tactical RMM Agent https://github.com/amidaware/tacticalrmm -#### building the agent +#### building the agent - linux ``` env CGO_ENABLED=0 GOOS= GOARCH= go build -ldflags "-s -w" ``` +#### building the agent - windows +``` +$env:CGO_ENABLED="0";$env:GOOS="windows";$env:GOARCH="amd64"; go build -ldflags "-s -w" +``` + ### tests Navigate to agent directory ``` diff --git a/agent/agent_windows.go b/agent/agent_windows.go index 2d6d1e1..5d75b2d 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -48,10 +48,6 @@ var ( func NewAgentConfig() *rmm.AgentConfig { k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - if shared.TEST { - err = nil - k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - } if err != nil { return &rmm.AgentConfig{} @@ -840,11 +836,6 @@ func (a *Agent) InstallService() error { // skip on first call of inno setup if this is a new install _, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - if shared.TEST { - err = nil - k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - } - if err != nil { return nil } diff --git a/agent/install.go b/agent/install.go index 6beaefb..d13c6f9 100644 --- a/agent/install.go +++ b/agent/install.go @@ -23,7 +23,6 @@ import ( "strings" "time" - "github.com/amidaware/rmmagent/shared" "github.com/go-resty/resty/v2" trmm "github.com/wh1te909/trmm-shared" ) @@ -253,15 +252,10 @@ func (a *Agent) Install(i *Installer) { a.Logger.Infoln("Starting service...") out := a.ControlService(winSvcName, "start") - if shared.TEST { - goto SKIPSTART; - } - if !out.Success { a.installerMsg(out.ErrorMsg, "error", i.Silent) } - SKIPSTART: a.Logger.Infoln("Skipping service start in test.") a.Logger.Infoln("Adding windows defender exclusions") a.addDefenderExlusions() diff --git a/agent/install_linux.go b/agent/install_linux.go index 7391609..550f275 100644 --- a/agent/install_linux.go +++ b/agent/install_linux.go @@ -39,9 +39,6 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me viper.Set("meshdir", meshdir) viper.SetConfigPermissions(0660) configLocation := "/etc/tacticalagent" - if shared.TEST { - configLocation = "tacticalagent" - } err := viper.SafeWriteConfigAs(configLocation) diff --git a/agent/install_windows.go b/agent/install_windows.go index db6467b..be46f2e 100644 --- a/agent/install_windows.go +++ b/agent/install_windows.go @@ -17,18 +17,12 @@ import ( "os" "path/filepath" - "github.com/amidaware/rmmagent/shared" "github.com/gonutz/w32/v2" "golang.org/x/sys/windows/registry" ) func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, meshdir string) { k, _, err := registry.CreateKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - if shared.TEST { - err = nil - k, _, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - } - if err != nil { log.Fatalln("Error creating registry key:", err) } @@ -84,10 +78,6 @@ func createAgentConfig(baseurl, agentid, apiurl, token, agentpk, cert, proxy, me func (a *Agent) checkExistingAndRemove(silent bool) { hasReg := false _, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - if shared.TEST { - err = nil - _, err = registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS) - } if err == nil { hasReg = true