Skip to content

Commit

Permalink
fix sudo detection
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle authored and rafaeldtinoco committed Oct 9, 2023
1 parent 9bbf4a8 commit ed5c276
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/utils/btf.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"debug/elf"
"fmt"
"os"
"os/exec"
"strings"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed5c276

Please sign in to comment.