github.com/dkerwin/nomad@v0.3.3-0.20160525181927-74554135514b/client/driver/exec_unix.go (about) 1 // +build darwin dragonfly freebsd linux netbsd openbsd solaris 2 3 package driver 4 5 import ( 6 "github.com/hashicorp/nomad/client/config" 7 "github.com/hashicorp/nomad/nomad/structs" 8 "golang.org/x/sys/unix" 9 ) 10 11 func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) { 12 // Get the current status so that we can log any debug messages only if the 13 // state changes 14 _, currentlyEnabled := node.Attributes[execDriverAttr] 15 16 // Only enable if cgroups are available and we are root 17 if _, ok := node.Attributes["unique.cgroup.mountpoint"]; !ok { 18 if currentlyEnabled { 19 d.logger.Printf("[DEBUG] driver.exec: cgroups unavailable, disabling") 20 } 21 delete(node.Attributes, execDriverAttr) 22 return false, nil 23 } else if unix.Geteuid() != 0 { 24 if currentlyEnabled { 25 d.logger.Printf("[DEBUG] driver.exec: must run as root user, disabling") 26 } 27 delete(node.Attributes, execDriverAttr) 28 return false, nil 29 } 30 31 if !currentlyEnabled { 32 d.logger.Printf("[DEBUG] driver.exec: exec driver is enabled") 33 } 34 node.Attributes[execDriverAttr] = "1" 35 return true, nil 36 }