On Linux, attempt to read from /sys/class/dmi/id/product_uuid first

before falling back to kernel.random.boot_id.

`/sys/class/dmi/id/product_uuid` is still managed by permissions, so
for root-run processes where `/sys/class/dmi/id/product_uuid` is
available, the host's UUID will be used instead, otherwise the UUID
from kernel.random.boot_id will be used instead.
pull/237/head
Sean Chittenden 9 years ago
parent 59094cd5b7
commit d490d634ca
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16

@ -61,10 +61,21 @@ func Info() (*InfoStat, error) {
ret.Procs = numProcs ret.Procs = numProcs
} }
sysProductUUID := common.HostSys("class/dmi/id/product_uuid")
switch {
case common.PathExists(sysProductUUID):
lines, err := common.ReadLines(sysProductUUID)
if err == nil && len(lines) > 0 && lines[0] != "" {
ret.HostID = lines[0]
break
}
fallthrough
default:
values, err := common.DoSysctrl("kernel.random.boot_id") values, err := common.DoSysctrl("kernel.random.boot_id")
if err == nil && len(values) == 1 && values[0] != "" { if err == nil && len(values) == 1 && values[0] != "" {
ret.HostID = values[0] ret.HostID = values[0]
} }
}
return ret, nil return ret, nil
} }

Loading…
Cancel
Save