Skip to content

Commit ccbc094

Browse files
authored
Merge pull request #3240 from larsewi/dmi-sysfs-isreadable
DMI inventory now skips sysfs files that `cf-agent` cannot read
2 parents f3f1ef5 + 640062b commit ccbc094

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎inventory/any.cf‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,17 @@ bundle agent cfe_autorun_inventory_dmidecode
11671167
"dmi[$(dmivars)]"
11681168
unless => isvariable("dmi[$(dmivars)]"),
11691169
# This is just for system-uuid really, which we get from the awk script above by preference.
1170+
@if minimum_version(3.22.0)
1171+
# Some files (e.g. product_serial) are only readable by root.
1172+
# The isreadable() was introduced in CFEngine 3.22.
1173+
if => isreadable(
1174+
"/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])", 1
1175+
),
1176+
@else
11701177
if => fileexists(
11711178
"/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])"
11721179
),
1180+
@endif
11731181
string => readfile(
11741182
"/sys/devices/virtual/dmi/id/$(sysfs_name_for[$(dmivars)])", 0
11751183
),

0 commit comments

Comments
 (0)