machine-drivers / docker-machine-driver-xhyve

docker-machine/minikube/minishift driver plugin for xhyve/hyperkit (native macOS hypervisor.framework)
https://godoc.org/github.com/machine-drivers/docker-machine-driver-xhyve
BSD 3-Clause "New" or "Revised" License
888 stars 74 forks source link

Show a nice warning when running without root #64

Closed johanneswuerbach closed 8 years ago

johanneswuerbach commented 8 years ago

Currently users running docker-machine create -d xhyve test without root are receiving an ugly error message Error creating machine: Error in driver during machine creation: exit status 1

Instead this driver should print a nice warning and tell the users that root is required.

zchee commented 8 years ago

@johanneswuerbach Yes, I think so, too.

I tried os.Chown(os.Args[0], 0, 0) on PreCreateCheck(), but does not work. Maybe caused by first run command user to has not root permission.

I think, the uid check insert to PreCreateCheck()

e.g. (example code. too dirty.)

// Print driver version, Check VirtualBox version
func (d *Driver) PreCreateCheck() error {
    .
    .
    .
    bin, err := os.Stat(os.Args[0])
    if err != nil {
        return err
    }
    if int(bin.Sys().(*syscall.Stat_t).Uid) == 501 {
        log.Infof("docker-machine-driver-xhyve need root owner. See https://github.com/zchee/docker-machine-driver-xhyve#install")
        os.Exit(1)
    }

    return nil
}

What do you think?

johanneswuerbach commented 8 years ago

Yep, exactly like this :+1:

zchee commented 8 years ago

@johanneswuerbach :) If has been merged PR on homebrew, I will add this method. and, Bump version v0.2.2 to later.

zchee commented 8 years ago

@johanneswuerbach I created a pull-request :) https://github.com/zchee/docker-machine-driver-xhyve/pull/75

zchee commented 8 years ago

Merged https://github.com/zchee/docker-machine-driver-xhyve/commit/278eb5a18af59264ddc5dd0492f78d853beae293.

If you find a bug, Could you tell me? and, I will increase the more test for the future.

Close.

korsmakolnikov commented 8 years ago

this is really annoying. I still have this issue on mac os 10.11.4