diff --git a/agent/agent_unix.go b/agent/agent_unix.go index 993b446..9d23590 100644 --- a/agent/agent_unix.go +++ b/agent/agent_unix.go @@ -209,6 +209,13 @@ func SetDetached() *syscall.SysProcAttr { return &syscall.SysProcAttr{Setpgid: true} } +func (a *Agent) seEnforcing() bool { + opts := a.NewCMDOpts() + opts.Command = "getenforce" + out := a.CmdV2(opts) + return out.Status.Exit == 0 && strings.Contains(out.Stdout, "Enforcing") +} + func (a *Agent) AgentUpdate(url, inno, version string) { self, err := os.Executable() @@ -276,6 +283,13 @@ func (a *Agent) AgentUpdate(url, inno, version string) { } } + if a.seEnforcing() { + se := a.NewCMDOpts() + se.Command = fmt.Sprintf("restorecon -rv %s", self) + out := a.CmdV2(se) + a.Logger.Debugln("%+v\n", out) + } + opts := a.NewCMDOpts() opts.Detached = true opts.Command = "systemctl restart tacticalagent.service"