Skip to content

Commit

Permalink
Prompt user if process running on Mac not under sudo (#128)
Browse files Browse the repository at this point in the history
* [feat] Prompt user and exit if process on macOS is not running with sudo privileges

* clear code

* clear code
  • Loading branch information
zzzk1 authored Sep 3, 2024
1 parent 781210e commit 7d92b65
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func Main() {
klog.Infof("FLAG: --%s=%q", flag.Name, flag.Value)
})

// Process on macOS must run using sudo
if runtime.GOOS == "darwin" && syscall.Geteuid() != 0 {
klog.Fatalf("Please run this again with `sudo`.")
}

// trap Ctrl+C and call cancel on the context
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
Expand Down

0 comments on commit 7d92b65

Please sign in to comment.