Skip to content

Commit

Permalink
Issue : #4420 - Provide warning message for unnecessary sudo
Browse files Browse the repository at this point in the history
Fixes #4420. If minikue is started with root privilege and vm-driver is
not hyperv, then a warning message is displayed.
  • Loading branch information
Deepjyoti Mondal committed Jun 10, 2019
1 parent 6aa51c1 commit 69f0d19
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strconv"
Expand Down Expand Up @@ -172,6 +173,13 @@ func runStart(cmd *cobra.Command, args []string) {
console.OutStyle(console.Happy, "minikube %s on %s (%s)", version.GetVersion(), runtime.GOOS, runtime.GOARCH)
validateConfig()

currentUser, err := user.Current()

// Display warning if minikube is being started with root and vmDriver is not hyperv
if err == nil && currentUser.Name == "root" && viper.GetString(vmDriver) != "hyperv" {
console.OutStyle(console.WarningType, "Please don't run minikube as root or with 'sudo' privileges. It isn't necessary.")
}

oldConfig, err := cfg.Load()
if err != nil && !os.IsNotExist(err) {
exit.WithCode(exit.Data, "Unable to load config: %v", err)
Expand Down

0 comments on commit 69f0d19

Please sign in to comment.