Skip to content

Commit

Permalink
Minor hardening
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hiltgen committed Sep 17, 2015
1 parent d860ddf commit 4852a3e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
const (
connectionString = "qemu:///system"
privateNetworkName = "docker-machines"
dockerConfigDir = "/var/lib/boot2docker"
isoFilename = "boot2docker.iso"
dnsmasqLeases = "/var/lib/libvirt/dnsmasq/%s.leases"
dnsmasqStatus = "/var/lib/libvirt/dnsmasq/%s.status"
Expand Down Expand Up @@ -517,7 +516,10 @@ func (d *Driver) getMAC() (string, error) {
return "", err
}
// Always assume the second interface is the one we want
// TODO harden
if len(dom.Devices.Interfaces) < 2 {
return "", fmt.Errorf("VM doesn't have enough network interfaces. Expected at least 2, found %d",
len(dom.Devices.Interfaces))
}
return dom.Devices.Interfaces[1].Mac.Address, nil
}

Expand Down Expand Up @@ -580,6 +582,7 @@ func (d *Driver) getIPByMacFromSettings(mac string) (string, error) {
}

func (d *Driver) GetIP() (string, error) {
log.Debugf("GetIP called for %s", d.MachineName)
mac, err := d.getMAC()
if err != nil {
return "", err
Expand Down

0 comments on commit 4852a3e

Please sign in to comment.