Skip to content

Commit

Permalink
Merge pull request #4455 from djmgit/sudo_message
Browse files Browse the repository at this point in the history
Provide warning message for unnecessary sudo
  • Loading branch information
tstromberg authored Jun 24, 2019
2 parents a702ce6 + 2cee972 commit ce74af2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 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 @@ -174,6 +175,15 @@ 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 {
glog.Errorf("Error getting the current user: %v", err)
} else if currentUser.Name == "root" && !(viper.GetString(vmDriver) == "hyperv" || viper.GetString(vmDriver) == "none") {
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 ce74af2

Please sign in to comment.