Skip to content

Commit

Permalink
Check if user has sudo permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Git-Jiro committed Nov 1, 2020
1 parent 4da751f commit 427daf6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/minikube/registry/drvs/none/none.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ func status() registry.State {
return registry.State{Running: true, Error: err, Installed: false, Fix: "Install docker", Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"}
}

_, err = user.Current()
u, err := user.Current()
if err != nil {
return registry.State{Running: true, Error: err, Healthy: false, Doc: "https://minikube.sigs.k8s.io/docs/reference/drivers/none/"}
}

if u.Uid != "0" {
test := exec.Command("sudo", "-n", "echo", "-n")
if err := test.Run(); err != nil {
return registry.State{Error: fmt.Errorf("running the 'none' driver as a regular user requires sudo permissions"), Healthy: false}
}
}
return registry.State{Installed: true, Healthy: true}
}

0 comments on commit 427daf6

Please sign in to comment.