From 27ec6a0789cefd42d1aa3ea7455b48fce7a401db Mon Sep 17 00:00:00 2001 From: Lomanic Date: Sat, 2 Mar 2019 22:21:28 +0100 Subject: [PATCH] [host][linux] Remove call to sysctl binary in host/host_linux.go #639 --- host/host_linux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/host/host_linux.go b/host/host_linux.go index 2c1ac6b..508d8c9 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -74,6 +74,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) { sysProductUUID := common.HostSys("class/dmi/id/product_uuid") machineID := common.HostEtc("machine-id") + procSysKernelRandomBootID := common.HostProc("sys/kernel/random/boot_id") switch { // In order to read this file, needs to be supported by kernel/arch and run as root // so having fallback is important @@ -95,9 +96,9 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) { fallthrough // Not stable between reboot, but better than nothing default: - values, err := common.DoSysctrl("kernel.random.boot_id") - if err == nil && len(values) == 1 && values[0] != "" { - ret.HostID = strings.ToLower(values[0]) + lines, err := common.ReadLines(procSysKernelRandomBootID) + if err == nil && len(lines) > 0 && lines[0] != "" { + ret.HostID = strings.ToLower(lines[0]) } }