do not rely on /proc/sys/kernel/random/uuid as fallback as it does not exists everywhere
@@ -17,6 +17,7 @@ import (
"github.com/crowdsecurity/machineid"
"github.com/enescakir/emoji"
"github.com/go-openapi/strfmt"
+ "github.com/google/uuid"
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
@@ -39,10 +40,6 @@ var (
digits = "0123456789"
)
-const (
- uuid = "/proc/sys/kernel/random/uuid"
-)
-
func generatePassword(length int) string {
charset := upper + lower + digits
@@ -70,9 +67,9 @@ func generateIDPrefix() (string, error) {
}
log.Debugf("failed to get machine-id with usual files: %s", err)
- bID, err := ioutil.ReadFile(uuid)
+ bId, err := uuid.NewRandom()
if err == nil {
- return string(bID), nil
+ return bId.String(), nil
}
return "", errors.Wrap(err, "generating machine id")
}
