From 562ad24715ef96289dee8b0199c687a09497ca07 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 29 Jan 2026 16:31:15 +0100 Subject: [PATCH] Improve path readability check On modern system e.g. render nodes are made accessible via the udev uaccess functionality, which adds the logged in user to the ACL of the device. This means just checking for user and group is bound to give false positives. Instead use os.access as a first check Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- amdsmi_cli/amdsmi_helpers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/amdsmi_cli/amdsmi_helpers.py b/amdsmi_cli/amdsmi_helpers.py index e30e433a5..d89025724 100755 --- a/amdsmi_cli/amdsmi_helpers.py +++ b/amdsmi_cli/amdsmi_helpers.py @@ -1252,6 +1252,11 @@ def _has_read_access(self, path: str) -> Tuple[bool, Optional[int], Optional[str if os.geteuid() == 0: return True, None, None + # Use os.access to check read permission (including ACLs) without + # opening the path, to avoid potential issues with device nodes. + if os.access(path, os.R_OK): + return True, None, None + mode = st.st_mode uid = st.st_uid gid = st.st_gid