Преглед на файлове

do not rely on /proc/sys/kernel/random/uuid as fallback as it does not exists everywhere (#1575)

blotus преди 3 години
родител
ревизия
b7f1c5455f
променени са 1 файла, в които са добавени 3 реда и са изтрити 6 реда
  1. 3 6
      cmd/crowdsec-cli/machines.go

+ 3 - 6
cmd/crowdsec-cli/machines.go

@@ -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")
 }