Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 18, 2025

The get_machine() function in the admin module was generating error messages when DMI files didn't exist on certain systems (containers, virtual machines, etc.). These error messages were being displayed to users even though the function was designed to handle missing files gracefully.

Problem

When DMI files like /sys/devices/virtual/dmi/id/board_vendor don't exist, the cat commands would output error messages to stderr:

cat: /sys/devices/virtual/dmi/id/board_vendor: No such file or directory
cat: /sys/devices/virtual/dmi/id/product_name: No such file or directory
cat: /sys/devices/virtual/dmi/id/board_name: No such file or directory
cat: /sys/devices/virtual/dmi/id/bios_version: No such file or directory
cat: /sys/devices/virtual/dmi/id/bios_date: No such file or directory

Solution

Modified the get_machine() function in Modules/admin/admin_model.php to redirect stderr to /dev/null for all DMI file read operations. This suppresses the error messages while maintaining all existing functionality.

Before:

$res = $this->exec('cat /sys/devices/virtual/dmi/id/board_vendor');

After:

$res = $this->exec('cat /sys/devices/virtual/dmi/id/board_vendor 2>/dev/null');

Testing

  • ✅ Verified no error messages are displayed when DMI files don't exist
  • ✅ Confirmed existing functionality works when DMI files are present
  • ✅ Tested both partial and complete file missing scenarios
  • ✅ Function continues to return appropriate machine information when available

The fix is minimal and surgical - it only adds 2>/dev/null to suppress stderr output while maintaining all existing functionality for systems where DMI files are available.

Fixes #1907.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: TrystanLea <503186+TrystanLea@users.noreply.github.com>
Copilot AI changed the title [WIP] cat: /sys/devices/virtual/dmi/id/*: No such file or directory Fix DMI file access error messages by suppressing stderr output Jul 18, 2025
Copilot AI requested a review from TrystanLea July 18, 2025 08:48
@TrystanLea TrystanLea marked this pull request as ready for review July 18, 2025 08:49
@TrystanLea TrystanLea merged commit f4c3f32 into master Jul 18, 2025
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.

cat: /sys/devices/virtual/dmi/id/*: No such file or directory

2 participants