fix agent update when selinux is enforcing fixes amidaware/tacticalrmm#1239

This commit is contained in:
wh1te909 2022-08-08 23:07:34 +00:00
parent adee74ffd0
commit 381f9696eb

View File

@ -209,6 +209,13 @@ func SetDetached() *syscall.SysProcAttr {
return &syscall.SysProcAttr{Setpgid: true} 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) { func (a *Agent) AgentUpdate(url, inno, version string) {
self, err := os.Executable() 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 := a.NewCMDOpts()
opts.Detached = true opts.Detached = true
opts.Command = "systemctl restart tacticalagent.service" opts.Command = "systemctl restart tacticalagent.service"