From 43eac3eb406eb95ab40ddc07442e0dcd0834642b Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 31 Aug 2022 17:55:07 +0200 Subject: [PATCH] validate systemctl command --- service_systemd_linux.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service_systemd_linux.go b/service_systemd_linux.go index 45eafe3..74e48cc 100644 --- a/service_systemd_linux.go +++ b/service_systemd_linux.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "os" + "os/exec" "os/signal" "path/filepath" "regexp" @@ -22,6 +23,9 @@ func isSystemd() bool { if _, err := os.Stat("/run/systemd/system"); err == nil { return true } + if _, err = exec.LookPath("systemctl"); err != nil { + return false + } if _, err := os.Stat("/proc/1/comm"); err == nil { filerc, err := os.Open("/proc/1/comm") if err != nil {