"github.com/AlecAivazis/survey/v2"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
"github.com/crowdsecurity/crowdsec/pkg/database"
- "github.com/denisbrodbeck/machineid"
+ "github.com/crowdsecurity/crowdsec/pkg/machineid"
"github.com/enescakir/emoji"
"github.com/go-openapi/strfmt"
"github.com/olekukonko/tablewriter"
github.com/containerd/containerd v1.4.3 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/davecgh/go-spew v1.1.1
- github.com/denisbrodbeck/machineid v1.0.1
github.com/dghubble/sling v1.3.0
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v20.10.2+incompatible
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
-github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
github.com/dghubble/sling v1.3.0 h1:pZHjCJq4zJvc6qVQ5wN1jo5oNZlNE0+8T/h0XeXBUKU=
github.com/dghubble/sling v1.3.0/go.mod h1:XXShWaBWKzNLhu2OxikSNFrlsvowtz4kyRuXUG7oQKY=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
--- /dev/null
+package machineid
+
+import (
+ "io/ioutil"
+ "strings"
+)
+
+const (
+ // dbusPath is the default path for dbus machine id.
+ dbusPath = "/var/lib/dbus/machine-id"
+ // dbusPathEtc is the default path for dbus machine id located in /etc.
+ // Some systems (like Fedora 20) only know this path.
+ // Sometimes it's the other way round.
+ dbusPathEtc = "/etc/machine-id"
+)
+
+// idea of code is stolen from https://github.com/denisbrodbeck/machineid/
+// but here we are on Debian GNU/Linux
+func ID() (string, error) {
+ id, err := ioutil.ReadFile(dbusPath)
+ if err != nil {
+ // try fallback path
+ id, err = ioutil.ReadFile(dbusPathEtc)
+ }
+ if err != nil {
+ return "", err
+ }
+ return strings.TrimSpace(string(id)), nil
+}