Skip to content

DMI inventory now skips sysfs files that cf-agent cannot read - #3240

Merged
larsewi merged 1 commit into
cfengine:masterfrom
larsewi:dmi-sysfs-isreadable
Nov 12, 2026
Merged

larsewi merged 1 commit into
cfengine:masterfrom
larsewi:dmi-sysfs-isreadable

Conversation

@larsewi

@larsewi larsewi commented Nov 8, 2026

Copy link
Copy Markdown
Contributor
  • Some files in /sys/devices/virtual/dmi/id/, such as product_serial, are only readable by root. The fileexists() guard let readfile() run anyway, so unprivileged agents logged CfReadFile: Error while reading file '/sys/devices/virtual/dmi/id/product_serial' (Permission denied).
  • This makes every masterfiles acceptance test fail with "Error printed" on runners that expose product_serial (e.g. the enterprise masterfiles_acceptance_tests job).
  • On 3.22.0 and later the read is now guarded by isreadable(), like /sys/hypervisor/uuid further up. Older agents keep fileexists().

🤖 Generated with Claude Code

@larsewi

larsewi commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi

larsewi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@larsewi
larsewi marked this pull request as ready for review November 9, 2026 13:19

@craigcomstock craigcomstock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also mention why 3.22 in the commit comment.

Comment thread inventory/any.cf Resolved
@larsewi
larsewi force-pushed the dmi-sysfs-isreadable branch from a4b5851 to f85fc2a Compare November 10, 2026 10:09
Some files in `/sys/devices/virtual/dmi/id/`, such as `product_serial`,
are only readable by root. `fileexists()` lets `readfile()` run anyway,
causing unprivileged agents to log a permission denied error.

Instead we use `isreadable()` to guard the read. However, `isreadable()`
is only available in CFEngine >= 3.22.

Changelog: Title
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi
larsewi force-pushed the dmi-sysfs-isreadable branch from f85fc2a to 640062b Compare November 10, 2026 10:11
@larsewi larsewi added the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Nov 10, 2026
@larsewi

larsewi commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

@craigcomstock craigcomstock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get it green! looks good!

@larsewi

larsewi commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@cf-bottom Jenkins please :)

@cfengine cfengine deleted a comment from cf-bottom Nov 11, 2026
@cfengine cfengine deleted a comment from cf-bottom Nov 12, 2026
@cf-bottom

Copy link
Copy Markdown

@larsewi
larsewi merged commit ccbc094 into cfengine:master Nov 12, 2026
41 of 42 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport to 3.24.x failed, manual backport needed: https://github.com/cfengine/masterfiles/actions/runs/43260187303

@github-actions

Copy link
Copy Markdown
Contributor

Backport to 3.27.x failed, manual backport needed: https://github.com/cfengine/masterfiles/actions/runs/43260187303

@larsewi

larsewi commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

@larsewi larsewi removed the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants