From 4315276e519c7d93c888045abbce19036d5d0f5a Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Thu, 28 Sep 2023 18:47:23 -0700 Subject: [PATCH] fix sudo detection --- pkg/utils/btf.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/utils/btf.go b/pkg/utils/btf.go index 56b9223f..07f8b0b8 100644 --- a/pkg/utils/btf.go +++ b/pkg/utils/btf.go @@ -5,7 +5,6 @@ import ( "context" "debug/elf" "fmt" - "os" "os/exec" "strings" ) @@ -37,7 +36,8 @@ func RunCMD(ctx context.Context, cwd string, binary string, args ...string) erro } func SudoCMD(binary string, args ...string) (string, []string) { - if os.Getuid() != 0 { + _, err := exec.LookPath("sudo") + if err == nil { return "sudo", append([]string{binary}, args...) } return binary, args