From 890ea42749dc821df7001266e66deeb905d99145 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:27:57 +0800 Subject: [PATCH] fix: Fix ClamAV service name detection issue (#9292) --- backend/utils/systemctl/managers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/utils/systemctl/managers.go b/backend/utils/systemctl/managers.go index 1302923a1..8d90f1fe1 100644 --- a/backend/utils/systemctl/managers.go +++ b/backend/utils/systemctl/managers.go @@ -23,7 +23,7 @@ var ( ) const ( - defaultCommandTimeout = 30 * time.Second + defaultCommandTimeout = 60 * time.Second serviceCheckTimeout = 5 * time.Second ) @@ -207,11 +207,11 @@ func (m *systemdManager) ServiceExists(config *ServiceConfig) (bool, error) { return m.commonServiceExists(config, func(name string) (bool, error) { ctx, cancel := context.WithTimeout(context.Background(), serviceCheckTimeout) defer cancel() - out, cmdErr := executeCommand(ctx, m.cmdTool, "list-unit-files", name) - if cmdErr != nil { - return false, fmt.Errorf("systemctl list-unit-files failed: %w", cmdErr) + out, cmdErr := executeCommand(ctx, m.cmdTool, "is-enabled", name) + if cmdErr == nil || strings.Contains(string(out), "disabled") { + return true, nil } - return bytes.Contains(out, []byte(name)), nil + return false, nil }) }