diff --git a/pkg/drivers/hyperkit/driver.go b/pkg/drivers/hyperkit/driver.go index 5632fe3c7731..78729b775b28 100644 --- a/pkg/drivers/hyperkit/driver.go +++ b/pkg/drivers/hyperkit/driver.go @@ -40,6 +40,9 @@ const ( isoFilename = "boot2docker.iso" pidFileName = "hyperkit.pid" machineFileName = "hyperkit.json" + permErr = "%s needs to run with elevated permissions. " + + "Please run the following command, then try again: " + + "sudo chown root:wheel %s && sudo chmod u+s %s" ) type Driver struct { @@ -61,6 +64,20 @@ func NewDriver(hostName, storePath string) *Driver { } } +// PreCreateCheck is called to enforce pre-creation steps +func (d *Driver) PreCreateCheck() error { + exe, err := os.Executable() + if err != nil { + return err + } + + if syscall.Geteuid() != 0 { + return fmt.Errorf(permErr, filepath.Base(exe), exe, exe) + } + + return nil +} + func (d *Driver) Create() error { // TODO: handle different disk types. if err := pkgdrivers.MakeDiskImage(d.BaseDriver, d.Boot2DockerURL, d.DiskSize); err != nil {