From a4b5851b9f89083018f48ec1aa315141dbbc99d1 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Sun, 8 Nov 2026 15:40:06 +0100 Subject: [PATCH] DMI inventory now skips sysfs files that `cf-agent` cannot read Some files in `/sys/devices/virtual/dmi/id/`, such as `product_serial`, are only readable by root. `fileexists()` let `readfile()` run anyway, so unprivileged agents logged a permission denied error. On 3.22.0 and later, `isreadable()` guards the read instead. Changelog: Title Signed-off-by: Lars Erik Wik --- inventory/any.cf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inventory/any.cf b/inventory/any.cf index 80cdb481d4..5fad95f818 100644 --- a/inventory/any.cf +++ b/inventory/any.cf @@ -1167,9 +1167,16 @@ bundle agent cfe_autorun_inventory_dmidecode "dmi[$(dmivars)]" unless => isvariable("dmi[$(dmivars)]"), # This is just for system-uuid really, which we get from the awk script above by preference. +@if minimum_version(3.22.0) + # Some files (e.g. product_serial) are only readable by root. + if => isreadable( + "/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])", 1 + ), +@else if => fileexists( "/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])" ), +@endif string => readfile( "/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])", 0 ),