Error Handling for NewAgentConfig

This commit is contained in:
redanthrax 2022-08-19 10:56:56 -07:00
parent 89d7ec8242
commit 87c035cd39
3 changed files with 10 additions and 7 deletions

View file

@ -47,10 +47,10 @@ var (
getDriveType = windows.NewLazySystemDLL("kernel32.dll").NewProc("GetDriveTypeW")
)
func NewAgentConfig() *rmm.AgentConfig {
func NewAgentConfig() (*rmm.AgentConfig, error) {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TacticalRMM`, registry.ALL_ACCESS)
if err != nil {
return &rmm.AgentConfig{}
return &rmm.AgentConfig{}, err
}
baseurl, _, _ := k.GetStringValue("BaseURL")
@ -79,7 +79,7 @@ func NewAgentConfig() *rmm.AgentConfig {
NatsProxyPath: natsProxyPath,
NatsProxyPort: natsProxyPort,
NatsStandardPort: natsStandardPort,
}
}, nil
}
func (a *Agent) RunScript(code string, shell string, args []string, timeout int, runasuser bool) (stdout, stderr string, exitcode int, e error) {