Skip to content

fix: Use lscpu to detect lack of confinement#400

Open
farshidtz wants to merge 1 commit into
mainfrom
fix-hardware-obs-check
Open

fix: Use lscpu to detect lack of confinement#400
farshidtz wants to merge 1 commit into
mainfrom
fix-hardware-obs-check

Conversation

@farshidtz

@farshidtz farshidtz commented Jul 10, 2026

Copy link
Copy Markdown
Member

Auto engine selection is expected to use the set fallback when there is no access to detect the hardware. The fallback logic is broken since the auto-connected opengl interface now grants access to read /sys/bus/pci/devices. This path was being checked to assume unconfined installation, which now produces a false positive (hardware-observe not connected, confined installation) and result in errors while reading USB devices.

$ sudo stack-utils use-engine --auto --fallback=cpu
Error: scoring engines: getting machine info: getting devices: reading sysfs usb devices: reading sys/bus/usb/devices: open sys/bus/usb/devices: permission denied

This PR changes the logic and relies on lscpu command instead, similar to how it was being done before implementing the --fallback flag. This now improved to run lscpu with the absolute system path so that staging util-linux which adds lscpu at $SNAP/usr/bin/lscpu won't get around it.

$ sudo stack-utils use-engine --auto --fallback=cpu
Hardware information is unavailable; falling back to engine "cpu".

Copilot AI review requested due to automatic review settings July 10, 2026 21:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates snap confinement detection used by use-engine --auto to decide whether hardware information can be collected (and thus whether --fallback should be used), replacing a sysfs-based heuristic with an lscpu-based check due to changed interface permissions.

Changes:

  • Add an lscpu execution check in HardwareObservable() as a proxy for “installed without confinement”.
  • Remove the previous /sys/bus/pci/devices directory-read heuristic that is no longer reliable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/snap/snap.go
@farshidtz farshidtz requested a review from mrmara July 10, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants