Skip to content

Commit

Permalink
fix sudo detection
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Sep 29, 2023
1 parent 895c4c9 commit 4315276
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 4315276

Please sign in to comment.