diff --git a/Makefile b/Makefile index b2e92df9c1f..fe815f807aa 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ CSCLI_FOLDER = "./cmd/crowdsec-cli/" CROWDSEC_BIN = "crowdsec" CSCLI_BIN = "cscli" BUILD_CMD = "build" -MAKE = "make" +MAKE ?= "make" GOARCH=amd64 GOOS=linux diff --git a/cmd/crowdsec-cli/machines.go b/cmd/crowdsec-cli/machines.go index bbdf11c05e2..d0457645609 100644 --- a/cmd/crowdsec-cli/machines.go +++ b/cmd/crowdsec-cli/machines.go @@ -9,6 +9,7 @@ import ( "os" "strings" "time" + "runtime" "github.com/AlecAivazis/survey/v2" "github.com/crowdsecurity/crowdsec/pkg/csconfig" @@ -21,6 +22,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "gopkg.in/yaml.v2" + "golang.org/x/sys/unix" ) var machineID string @@ -65,11 +67,18 @@ func generateID() (string, error) { log.Debugf("failed to get machine-id with usual files : %s", err) } if id == "" || err != nil { - bID, err := ioutil.ReadFile(uuid) + var err error + var bID []byte + switch runtime.GOOS { + case "openbsd": + id, err = unix.Sysctl("hw.uuid") + default: + bID, err = ioutil.ReadFile(uuid) + id = string(bID) + } if err != nil { return "", errors.Wrap(err, "generating machine id") } - id = string(bID) } id = strings.ReplaceAll(id, "-", "")[:32] id = fmt.Sprintf("%s%s", id, generatePassword(16))